Microsoft KB Archive/249594

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Knowledge Base


Article ID: 249594

Article Last Modified on 12/1/2003



APPLIES TO

  • Microsoft Windows Internet Services (WinInet)
  • Microsoft Internet Explorer 4.0 128-Bit Edition
  • Microsoft Internet Explorer 4.01 Service Pack 2
  • Microsoft Internet Explorer 4.01 Service Pack 1
  • Microsoft Internet Explorer 4.01 Service Pack 2



This article was previously published under Q249594

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 that this is a bug in the Microsoft products that are 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.

177188 Using HttpSendRequestEx for Large POST Requests



Additional query words: HttpSendRequestEx HttpEndRequest

Keywords: kbbug kbfix KB249594