Windows 2000 IIS doesn't mind this, but Windows 2003 (IIS 6)
rejects the request if it sees both headers.
Is there a way to suppress the sending of Content-Length?
Thanks.
Mark Riordan
There is no official way to suppress the Content-Length request header,
although it might be possible with the following hack (which I have not
tried):
-- register a status callback function on the request handle using
WinHttpSetStatusCallback, specifying at least
WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER for the dwNotificationFlags
parameter
-- disable the keep-alive feature or set a "Connection: Close" request
header
-- use WinHttpWriteData to send your POST data (which I suspect you are
already doing); do not supply all of your POST data in a single buffer to
WinHttpSendRequest
-- during WinHttpSendRequest, when your callback gets the
CONNECTED_TO_SERVER notification, call:
WinHttpAddRequestHeaders(hRequest, L"Content-Length:", -1L,
WINHTTP_ADDREQ_FLAG_REPLACE);
The goal of this hack is to erase the Content-Length request header just
before WinHTTP sends the HTTP request.
- Stephen