Reputation: 184
Background: I'm maintaining an old C++ app that communicates with my company's servers. No one at the company (including me) has any significant experience with C++ or with many of the other technologies being used.
The problem: I am trying to upload a file with code that looks like this:
if(HttpSendRequestEx(hReq, &InBuf, NULL, HSR_INITIATE, 0))
{
unsigned long ulWrote;
BOOL bWrote;
bWrote = InternetWriteFile(hReq, postData, postDataLength, &ulWrote);
if(bWrote)
{
if(!HttpEndRequest(hReq, NULL, 0, 0))
{
DWORD errorCode = GetLastError(); // 12002 - timeout
}
}
}
There's lots of other error-handling going on here, but I've stripped it down to where I'm seeing a problem.
Small files will upload without a problem, larger files (~25MB) are encountering a timeout. Even though the timeout is occurring, many times the file will upload successfully, so I don't think it's a problem on the server side. Just suppressing or ignoring the error seems wrong but I haven't found any way to set the timeout to a more reasonable level.
Upvotes: 2
Views: 1073
Reputation: 175826
WININET provides InternetSetOption()
to control its behaviour, in your case look at the the INTERNET_OPTION_SEND_TIMEOUT
flag.
Upvotes: 3