Reputation: 1250
I'm trying to reach a web page on an embedded device. I'm using WinHttp on Win32. When trying to read response I get error
ERROR_WINHTTP_INVALID_SERVER_RESPONSE 12152 The server response cannot be parsed.
But when I captured with WireShark I can see that response is coming. So to test I wrote a simple C# program. GetResponse was throwing exception
The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF
So according to below solution I set useUnsafeHeaderParsing to true. And it worked fine.
Since I can't use C# I need to find a way to set useUnsafeHeaderParsing to true for WinHttp with win32 C++
Many thanks
Upvotes: 0
Views: 839
Reputation: 21
Looks like the name of the option must have changed since then: with the current SDK it's WINHTTP_OPTION_UNSAFE_HEADER_PARSING
. Also, I verified (by examining the Assembly code directly) that:
DWORD
-sizedObviously, since this undocumented, it's subject to change.
Upvotes: 0
Reputation: 3207
I've briefly looked into the option flags of WinHttpSetOption
and found the following entry:
WINHTTP_OPTION_UNSAFE_HEADER_BLOCKING This option is reserved for internal use and should not be called.
Since the option looks linke an on/off switch I would try to do the following:
BOOL bResult;
BOOL bOption = FALSE;
bResult = WinHttpSetOption(hInternet,
WINHTTP_OPTION_UNSAFE_HEADER_BLOCKING,
&bOption,
sizeof(bOption));
if (bResult == FALSE)
{
/* handle error with GetLastError() */
}
Well but as MSDN says it's reserved for internal use and therefore the function may change in the future (or has already changed in the past). But it's worth a try... Good Luck!
Upvotes: 1