HTTP response header

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
Alan5432
Posts: 5
Joined: Mon Sep 26, 2022 10:03 pm

HTTP response header

Post 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.
Scott Klement
Site Admin
Posts: 636
Joined: Sun Jul 04, 2021 5:12 am

Re: HTTP response header

Post by Scott Klement »

You can retrieve each header individually by calling the HTTP_HEADER procedure.

Code: Select all

  authString = http_header('www-authenticate');
akrash
Posts: 2
Joined: Tue May 02, 2023 4:33 pm

Re: HTTP response header

Post 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
Scott Klement
Site Admin
Posts: 636
Joined: Sun Jul 04, 2021 5:12 am

Re: HTTP response header

Post 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...
akrash
Posts: 2
Joined: Tue May 02, 2023 4:33 pm

Re: HTTP response header

Post 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.
Post Reply