BUG: WinInet MFC HTTP Classes Report Assertion When You Call SetOption or QueryInfo

Article translations Article translations
Article ID: 307485 - View products that this article applies to.
This article was previously published under Q307485
Expand all | Collapse all

SYMPTOMS

When you build the following code for the debug target, the SetOption method reports an assertion during run time:
CHttpFile *pFile;
pFile->SetOption (INTERNET_OPTION_CLIENT_CERT_CONTEXT,
(PVOID) pCert, sizeof (pCert));
				
The assertion also occurs with the following code:
CHttpFile->QueryOption (HTTP_QUERY_CUSTOM, ...)
				

CAUSE

This problem occurs because the following Microsoft Foundation Classes (MFC) code in the Inet.cpp file is not compiled with the latest WinInet.h file:
BOOL CInternetFile::SetOption(DWORD dwOption, LPVOID lpBuffer,
	DWORD dwBufferLength, DWORD dwFlags /* = 0 */)
{
	ASSERT(dwOption >= INTERNET_FIRST_OPTION &&
		dwOption <= INTERNET_LAST_OPTION);
...
				
In the most current WinInet.h file, the INTERNET_OPTION_CLIENT_CERT_CONTEXT option flag is greater than the INTERNET_LAST_OPTION option flag, which is used at the time of MFC compilation (that is, it is used to produce the debug version of MFC DLLs).

If this problem occurs with the following code:
CHttpFile->QueryOption (HTTP_QUERY_CUSTOM, ...)
				
the following ASSERT statement occurs in the Inet.cpp file:
ASSERT((HTTP_QUERY_HEADER_MASK & dwInfoLevel) <= HTTP_QUERY_MAX &&
		dwInfoLevel != 0);
				
The assertion is triggered when you use the HTTP_QUERY_CUSTOM option flag, although the MFC documentation states that this option works.

RESOLUTION

To resolve this problem, use the Win32 function in MFC directly as follows:
CHttpFile *pFile;
...
::InternetSetOption (*pFile, INTERNET_OPTION_CLIENT_CERT_CONTEXT, ...)
::InternetQueryOption (*pFile, HTTP_QUERY_CUSTOM)<BR/>
				

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Because ASSERT statements work in the debug build of the project, these problems in MFC are nothing but inconveniences. To work around this problem, you can modify the MFC source files for the MFC debug DLLs.

To build the MFC source files, use the makefile that is named Mfcdll.mak in the Mfc\Src directory of the Microsoft Visual C++ installation.

For more information about this topic, visit the following Microsoft Web site:
TN033: DLL Version of MFC
http://msdn.microsoft.com/en-us/library/hw85e4bb.aspx

REFERENCES

For more information, see the Visual C++ Help documentation.

Properties

Article ID: 307485 - Last Review: August 15, 2005 - Revision: 1.3
APPLIES TO
  • Microsoft Visual Studio 6.0 Enterprise Edition
Keywords: 
kbbug kbfix KB307485

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com