For it to work with huge data, do we need to set any content-length?
Do we need to split up data manually into smaller chunks before
sending?.
Here is our code...
hSession = WinHttpOpen( L"HTTP Channel",
WINHTTP_ACCESS_TYPE_NO_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS, 0);
if (hSession)
hConnect = WinHttpConnect( hSession, bstrServer,
dwPort, 0);
PreAuthenticateHTTPChannel(hConnect, bstrPreferredServer, dwSecurity);
if (hConnect)
hRequest = WinHttpOpenRequest(hConnect, L"POST",
bstrPreferredServer,
NULL, WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
dwSecurity);
LPCWSTR szHeader = L"Content-Type: application/x-www-form-urlencoded";
.....
bResults = WinHttpSendRequest( hRequest, szHeader, wcslen(szHeader),0,
0,
lDataLen, 0);
if (bResults)
bResults = WinHttpWriteData(hRequest, pByte, lDataLen,
&dwBytesWritten);
//lDataLen = 12029306
if(!bResults)
hr = GetLastError();
//hr=12030, ERROR_WINHTTP_CONNECTION_ERROR
Please Help.
-- Chetan
If your server requires authentication, can you confirm that the
PreAuthenticateHTTPChannel function is successfully authenticating with the
server? Also, do you know what kind of authentication the server uses
(Integrated Windows Authentication? Basic?)
If the pre-authentication request fails, and the server requires
authentication before it will accept your large POST request, the server may
abort the connection instead of waiting for your client to transmit all of
the POST data. I believe some servers, such as IIS (up to version 5.0), will
abort the connection before the client transmits all of a large POST
request. This would result in a WinHTTP connection error.
WinHTTP will set the Content-Type request header for you, based on the
dwTotalLength parameter of the WinHttpSendRequest API call.
You should first double check that the PreAuthenticateHTTPChannel function
is working. I wrote that function for someone on this newsgroup about 1
month ago. The function will send a HEAD request to the UrlPath (given by
your bstrPreferredServer string). If your bstrPreferredServer string
specifies an ASP/ASPX page, for example, the PreAuthenticate function may
fail because the server does not accept HEAD requests for an ASP/ASPX page.
So you may need to change the bstrPreferredServer parameter to
PreAuthenticateHTTPChannel to specify a static resource (e.g., something you
could send a GET request to), such as a dummy text file on the server.
Stephen
"HiChetu" <google...@gawab.com> wrote in message
news:d48e681e.04031...@posting.google.com...
"Stephen Sulzer" <sasulzer_at_seanet.com> wrote in message news:<105cf3l...@corp.supernews.com>...
WinHttpTraceCfg is available with the Windows Server 2003 Resource Toolkit.
(You can use WinHttpTraceCfg.exe on Windows 2000 and XP as well as Server
2003.) The Resource Toolkit is available at:
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en
Documentation about the WinHttpTraceCfg tool can be found at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winhttp/http/winhttptracecfg_exe__a_trace_configuration_tool.asp
Another thing to consider is that a timeout may be occurring. Did you
override the send timeout using the WinHttpSetTimeouts API? The default send
timeout is 30000 (30 seconds). Try setting a very large send timeout value,
say 120000. How fast is the net connection between your client and server
machines?
You should consider implementing a workaround. For multi-megabyte POST
payloads, use separate WinHttpWriteData calls for each 1 megabyte (or less)
chunk of data.
Internally in WinHTTP 5.x, WinHttpWriteData will simply pass your data
buffer down to Winsock. Winsock should not have any trouble with a 3MB
buffer. For buffers larger than 4MB, WinHttpWriteData will pass the data to
Winsock in 4MB chunks (similar to the workaround I mentioned above).
Hope that helps.
Stephen
"HiChetu" <google...@gawab.com> wrote in message
news:d48e681e.04031...@posting.google.com...
"Stephen Sulzer" <sasulzer_at_seanet.com> wrote in message news:<105dg2v...@corp.supernews.com>...