Page 1 of 1

HTTP response header

Posted: Wed Apr 05, 2023 12:11 am
by Alan5432
Is there any way to capture the response header instead of just the body/form data? I know I can interrogate the return code from something like http_req but I would find it useful to be able to examine the response header as well.

Re: HTTP response header

Posted: Wed Apr 05, 2023 5:08 am
by Scott Klement
You can retrieve each header individually by calling the HTTP_HEADER procedure.

Code: Select all

  authString = http_header('www-authenticate');

Re: HTTP response header

Posted: Tue May 02, 2023 4:38 pm
by akrash
Hi Scott,

Would this be a toll order to suggest that multiple occurrence data structure hdr (globally defined in module HEADERR4) be converted to an array data structure and exported out - so that a user application would be able to retrieve the response headers in their entirety at once?

Thanks,
Alex

Re: HTTP response header

Posted: Thu May 04, 2023 10:16 am
by Scott Klement
Can you explain why you would want a list of all headers?

If such a thing is truly needed, I don't think exposing the array directly is the best way to do it. Better is to provide a subprocedure that you can call to retrieve the whole list...

Re: HTTP response header

Posted: Thu May 04, 2023 2:26 pm
by akrash
Mostly for logging/reporting. We would want to store the response headers in a database for reference.

Depending on the application (and the nature of the response), we would want to be able to easily reference a particular header (e.g, via an SQL view), including the custom headers, without having to specifically address that header in a program via http_header(). For example, the services we are dealing with sometimes include a "correlation-id" header, which, in effect, points out the internal data on the server side. We use that as a troubleshooting resource.

IBM's table functions HTTP_POST_VERBOSE, HTTP_GET_VERBOSE, etc., do include the full list of HTTP response headers as a column. As a big fan of HTTPAPI, I would like to see it to be at least on par with IBM in this regard. In my opinion, it beats IBM solutions in many other regards!

If you see my request as a tentatively valid case but currently lack the time to implement it, I will volunteer my time to make that happen, if you trust me. I will code the new subprocedure in to return the headers and run the tests (unit tests followed by a regression testing using the applications that I have available), will present the results to you when ready.

Please let me know if this would be agreeable and thanks again, Scott.