Previous Thread
Next Thread
Print Thread
Receive Headers from xcall HTTP #37976 11 Apr 25 07:07 AM
Joined: Aug 2016
Posts: 411
J
John Andreasen Online Content OP
Member
OP Online Content
Member
J
Joined: Aug 2016
Posts: 411
Is there a way to get back the headers returned by the host during a xcall HTTP POST operation? I can see them in the debug.log, but do not see a way to get them back from the XCALL directly.

Re: Receive Headers from xcall HTTP [Re: John Andreasen] #37979 11 Apr 25 08:19 AM
Joined: Jun 2001
Posts: 11,945
J
Jack McGregor Offline
Member
Offline
Member
J
Joined: Jun 2001
Posts: 11,945
There's definitely a way to do that internally, but it's not exposed in the XCALL HTTP interface. We could rectify that easily enough, but it requires some kind of design decision...

Assuming you want the headers in addition to the body of the response (i.e. the response parameter), then we have to do one of the following:

  • Add another parameter. (On the one hand, this is the messiest, since it would have to follow the existing two optional parameters, and it would require updating both A-Shell and the dll/lib together. And it also raises the question of whether the XHTTPF_FILERESP option should apply to this new headers parameter in the same way that it does to the response parameter.)
  • Prepend or append it to the response. The complication here would be that the response typically has a specific format (xml, json, etc.) raising some questions about just how to combine the headers with it. But since it would be optional, I suppose we could adopt any kind of non-standard scheme to allow you to separate the two parts of the response.
  • Just put the headers in a file with a standardized name. In the case of a file response, the simplest approach would be to just use the same file name but with a .HDR extension. But in the non-file response, it's not obvious what file should be called -- headers.txt? <jobnam>.hdr?
  • Or some other idea?


Of course, if you only wanted the headers, then a new XHTTPF_HDRRESP flag could simply replace the existing response with one consisting of just the headers. But it doesn't seem likely that the headers would be useful by themselves.

I'm open to suggestions.

Re: Receive Headers from xcall HTTP [Re: John Andreasen] #37981 11 Apr 25 08:35 AM
Joined: Aug 2016
Posts: 411
J
John Andreasen Online Content OP
Member
OP Online Content
Member
J
Joined: Aug 2016
Posts: 411
I think any of those options would work. It seems like in the second option that you would be able to separate them as the headers would be at the beginning of the response and could be separated from the body of the response by a single blank line (as it is in the actual HTTP protocol.)

Re: Receive Headers from xcall HTTP [Re: John Andreasen] #37982 11 Apr 25 08:49 AM
Joined: Jun 2001
Posts: 11,945
J
Jack McGregor Offline
Member
Offline
Member
J
Joined: Jun 2001
Posts: 11,945
That sounds sensible to me. So we'll define a new flag XHTTPF_HDRRESP (or perhaps use the existing XHTTPF_REQHEAD) which if specified along with XHTTPF_REQPOST, will cause the headers to be prepended to the response with a blank line separating them from the rest of the response. It will just require an update of the ashnet library.

I'll shoot for early next week.

Re: Receive Headers from xcall HTTP [Re: John Andreasen] #37983 11 Apr 25 09:08 AM
Joined: Aug 2016
Posts: 411
J
John Andreasen Online Content OP
Member
OP Online Content
Member
J
Joined: Aug 2016
Posts: 411
OK, sounds good. Thank you

Re: Receive Headers from xcall HTTP [Re: John Andreasen] #37985 14 Apr 25 06:14 PM
Joined: Jun 2001
Posts: 11,945
J
Jack McGregor Offline
Member
Offline
Member
J
Joined: Jun 2001
Posts: 11,945
Ok, I think this is ready to go. It only requires an update to the ashnet library ...

ashnet-1.14.202-w32.zip
libashnet.so.1.14.202-el7.tz
libashnet.so.1.14.202-d12-x86_64.tz

The notes are pretty straightforward:
Quote
1. LIBASHNET update - libashnet.so.1.14.202 supports the ability to request
response headers along with the response body in a POST request by combining
both the XHTTPF_REQPOST and XHTTPF_REQHEAD flags. The headers will be at
the start of the response, separated from the body by a blank line.

Re: Receive Headers from xcall HTTP [Re: John Andreasen] #37986 16 Apr 25 12:25 PM
Joined: Aug 2016
Posts: 411
J
John Andreasen Online Content OP
Member
OP Online Content
Member
J
Joined: Aug 2016
Posts: 411
This seems to be working. Thank you

Re: Receive Headers from xcall HTTP [Re: John Andreasen] #37995 21 Apr 25 05:21 PM
Joined: Aug 2016
Posts: 411
J
John Andreasen Online Content OP
Member
OP Online Content
Member
J
Joined: Aug 2016
Posts: 411
Hi Jack,

For some reason when I am using this, it seems the headers and response are separated by <LF><CR> instead of <CR><LF>.
[Linked Image]
Is this a mistake or is the CR a side effect of something else? I have an example program I can send if needed.

Attached Files xcallHTTP_lfcr.png
Re: Receive Headers from xcall HTTP [Re: John Andreasen] #37996 21 Apr 25 05:46 PM
Joined: Jun 2001
Posts: 11,945
J
Jack McGregor Offline
Member
Offline
Member
J
Joined: Jun 2001
Posts: 11,945
Interesting. Looks like a dyslexic slip-up. I think it should be resolved in the 203 update of the library...

ashnet-1.14.203-w32.zip
libashnet.so.1.14.203-el7.tz
libashnet.so.1.14.203-d12-x86_64.tz

Last edited by Jack McGregor; 21 Apr 25 06:25 PM. Reason: Repost links
Re: Receive Headers from xcall HTTP [Re: John Andreasen] #37997 21 Apr 25 07:08 PM
Joined: Aug 2016
Posts: 411
J
John Andreasen Online Content OP
Member
OP Online Content
Member
J
Joined: Aug 2016
Posts: 411
This has fixed the issue. Thanks


Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3