1

I need to be able to log the outgoing request, which I am sending using winhttp. Everything else is easy to get (status code, content, response headers, etc) but there appears to be absolutely no way to see what winhttp is actually sending in the request headers.

I need to log the request headers because it contains a cookie from the login's set-cookie, but which is being rejected for unknown reasons from the application, whereas the same urls succeed in a browser.

I had to convert an older program based on afxinet because it needed to run as a service, which that interface can't do, so I moved to winhttp. Unfortunately winhttp has this glaring flaw in the api. Am I missing something, or is there a better option than winhttp? I could convert to curl if winhttp can't do this.

Kenny Ostrom
  • 5,639
  • 2
  • 21
  • 30

1 Answers1

3

WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_FLAG_REQUEST_HEADERS ...

See https://msdn.microsoft.com/en-us/library/aa384102.aspx

  • Oh wow, thanks. Not quite, but close enough. It is not documented in that link, but I was able to figure it out from winhttp.h, once I you gave me that constant to search for. Unfortunately, I replaced everything with curl a while back. (also runs on ubuntu and centos, now) – Kenny Ostrom Jun 11 '17 at 03:07
  • @KennyOstrom can you post your answer if you succeed to solve this question please – Guy Sadoun Nov 02 '21 at 09:53
  • It's been a while. I think it was just a bug in an earlier version of winhttp. Something like it couldn't have multiple cookies? I'll try to check again later today. – Kenny Ostrom Nov 02 '21 at 13:27