With WinHTTP, WinHttpReceiveResponse will return ERROR_WINHTTP_INVALID_SERVER_RESPONSE if there is something wrong with an HTTP header for example.
Is there anyway to get to the data that was returned, despite the fact that it was malformed?
With WinHTTP, WinHttpReceiveResponse will return ERROR_WINHTTP_INVALID_SERVER_RESPONSE if there is something wrong with an HTTP header for example.
Is there anyway to get to the data that was returned, despite the fact that it was malformed?
The direct approach would be to bypass the WinHTTP API in this case and do a "raw" read using a socket and do your best to try to interpret the response header.
If it's possible to find a line matching content-length
, you might, at least, be able to get all the data even though the header is invalid. To try this approach, either run your code in a debugger and look at what is actually sent by the web server or try to capture the packet stream and look inside the first packet to find the raw bytes.
You result will, obviously, depend on the actual problem with the response.