FIX: HttpSendRequstEx/HttpEndRequest Does Not Work with Proxy Authentication
ID: Q249594
|
The information in this article applies to:
-
Microsoft Internet Explorer (Programming) version 4.x
SYMPTOMS
When you submit a request to a server using HttpSendRequestEx and HttpEndRequest, HttpEndRequest will return an error 8 (ERROR_NOT_ENOUGH_MEMORY).
CAUSE
This error might occur if proxy authentication is required for the connection to the server. The WinInet APIs do not handle this situation correctly in 4.x versions of Internet Explorer.
RESOLUTION
Upgrade to Internet Explorer version 5 or later.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
This problem was corrected in Internet Explorer 5.
MORE INFORMATION
The following code will handle proxy authentication (in Internet Explorer 5) in the case of a proxy that requires basic authentication:
if(!HttpSendRequestEx( hRequest, &BufferIn, NULL, 0, 0))
// code between here and HttpEndRequest omitted for brevity
if(!HttpEndRequest(hRequest, NULL, 0, 0))
{
DWORD dwError = GetLastError();
printf( "Error on HttpEndRequest %lu \n", dwError);
return FALSE;
}
// Added to test proxyauth
DWORD dwSize, dwCode;
CHAR szData[51];
dwSize = sizeof (DWORD);
if ( !HttpQueryInfo (hRequest,
HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
&dwCode, &dwSize, NULL))
{
printf( "Error on HttpQueryInfo %lu \n", GetLastError());
return FALSE;
}
if ( dwCode == HTTP_STATUS_DENIED ||
dwCode == HTTP_STATUS_PROXY_AUTH_REQ)
{
// We have to read all outstanding data on the Internet handle
// before we can resubmit request. Just discard the data.
do
{
InternetReadFile (hRequest, (LPVOID)szData, 50, &dwSize);
}
while (dwSize != 0);
if ( InternetErrorDlg (GetDesktopWindow(), hRequest,
ERROR_INTERNET_INCORRECT_PASSWORD,
FLAGS_ERROR_UI_FILTER_FOR_ERRORS |
FLAGS_ERROR_UI_FLAGS_GENERATE_DATA |
FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS,
NULL) == ERROR_INTERNET_FORCE_RETRY)
goto again;
}
To see a sample implementation of this code, click the article number below to view the article in the Microsoft Knowledge Base.
Q177188 Using HttpSendRequestEx for Large POST Requests
Additional query words:
HttpSendRequestEx HttpEndRequest
Keywords : kbIE400bug kbIE401bug kbWinInet kbDSupport
Version : WINDOWS:4.x
Platform : WINDOWS
Issue type : kbbug