Peblem with HTTP POST when using WinHttpSendRequest

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am writing an application using WinHttp functions. The program is doing a HTTPS POST on to a web server. A snippet of the code is given below:
char post[] = "id=HarryPorter&pw=GoodMovie&Submit=Submit";
hSession = WinHttpOpen( L"TestProg/1.0", WINHTTP_ACCESS_TYPE_NO_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0 );<br/>
hConnect = WinHttpConnect( hSession, L"localhost", INTERNET_DEFAULT_HTTPS_PORT, 0 );<br/>
hRequest = WinHttpOpenRequest( hConnect, L"POST", L"/login.php", L"HTTP/1.1", WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_SECURE );
WinHttpSendRequest( hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, strlen(post), NULL );<br/>
WinHttpWriteData(hRequest, &post, strlen(post), lpdwNumberOfBytesWritten);<br/>
WinHttpReceiveResponse( hRequest, NULL );

The problem is that the POST data is getting sent twice. The content length is as per strlen(post). But the length of OST Data is 2*strlen(post) and the post is getting sent twice.
Can someone point out the mistake.
Thanks

View the full article
 
Back
Top