Discussion:
HttpAddRequestHeaders
(too old to reply)
Petar Popara
2005-09-08 08:55:23 UTC
Permalink
Although I can see that nobody is answering in this newsgroup, I'll post
this question.

How can I read HTTP header values from response? I need something like
HttpGetResponseHeaders().
Brian Cryer
2005-09-08 12:25:07 UTC
Permalink
Post by Petar Popara
Although I can see that nobody is answering in this newsgroup, I'll post
this question.
How can I read HTTP header values from response? I need something like
HttpGetResponseHeaders().
Petar,

rest assured that many people do read the postings to this newsgroup - but
if they are like me then they don't know all the answers.

To get the HTTP header values use HttpQueryInfo. To get all the response
headers you would need to pass in HTTP_QUERY_RAW_HEADERS_CRLF as the second
parameter. Other flags will get different responses back or in different
formats.

I have a Delphi example on my website -
http://www.cryer.co.uk/brian/delphi/wininet/example_isurlvalid.htm - which
shows how to use HttpQueryInfo to get back just the status code response. It
therefore uses HTTP_QUERY_STATUS_CODE rather than
HTTP_QUERY_RAW_HEADERS_CRLF, but it should give you a feel for how to use
it.

Hope this helps,

Brian.
--
www.cryer.co.uk/brian
Petar Popara
2005-09-13 09:57:47 UTC
Permalink
Thank you Brian for your help.

I have written some code to retrive HTTP headers, but I don't know where to
put HttpQueryInfo(). This is order of my WinINET function calls:

InternetOpen()
InternetConnect()
HttpOpenRequest()
HttpAddRequestHeaders()
HttpSendRequestEx()
HttpEndRequest()
HttpQueryInfo() // here?
InternetReadFile()
Petar Popara
2005-09-13 10:41:03 UTC
Permalink
Post by Petar Popara
InternetOpen()
InternetConnect()
HttpOpenRequest()
HttpAddRequestHeaders()
HttpSendRequestEx()
HttpEndRequest()
HttpQueryInfo() // here?
InternetReadFile()
Yes, that was right order. In the beginning I have expirienced some
difficulties, but it works now.

By looking at your Delphi example, I wonder why in my case HttpOpenRequest()
doesn't fail when I set wrong path (i.e. /MyApp/MyServlet)? Can I put
HttpQueryInfo() right after HttpOpenRequest() call (although it doesn't
fail)?

Loading...