Bhamid
2004-11-14 03:25:01 UTC
I set my PAC file URL in IE. This URL is internal to a corporate n/w.
When my application runs, the first HttpSendRequest is made from a network
that does not have access to the PAC file URL. This is successful.
After that the VPN tunnel is established, the PAC file URL is now valid;
however, the second HttpSendRequest fails with 12007. The PAC file does not
seem to get downloaded.
I released all the handles between the two requests, yet the second request
always fails. Any idea?
IE version is 6.0.2900. The requests are HTTPS (both)
Code snippet.
hOpen = pInternetOpen("MyApp", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (dwTimeout > 0)
{
pInternetSetOption(hOpen, INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeout,
sizeof(DWORD));
pInternetSetOption(hOpen, INTERNET_OPTION_SEND_TIMEOUT, &dwTimeout,
sizeof(DWORD));
}
DWORD dw = 20;
pInternetSetOption(hOpen, INTERNET_OPTION_CONNECT_RETRIES, &dw,
sizeof(DWORD));
hConnect = pInternetConnect(hOpen, urlInfo.lpszHostName, urlInfo.nPort, "",
"", INTERNET_SERVICE_HTTP, 0, 0);
CString bstrActionVerb = GET;
if (postDataLength > 0)
{
bstrActionVerb = POST;
}
char szAccept[] = "*/*";
LPSTR AcceptTypes[2]={0};
AcceptTypes[0]=szAccept;
DWORD dwFlag;
if (urlInfo.nScheme == INTERNET_SCHEME_HTTPS)
{
dwFlag = INTERNET_FLAG_SECURE |
INTERNET_FLAG_KEEP_CONNECTION |
INTERNET_FLAG_IGNORE_CERT_CN_INVALID |
INTERNET_FLAG_IGNORE_CERT_DATE_INVALID |
INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS |
INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP;
}
else
{
dwFlag = INTERNET_FLAG_KEEP_CONNECTION;
}
hRequest = pHttpOpenRequest(hConnect, bstrActionVerb,
urlInfo.lpszUrlPath,
HTTP_VERSION, "", (LPCSTR*) AcceptTypes,
dwFlag ,0);
if (hRequest == NULL) {
DWORD dwErr = GetLastError();
pInternetCloseHandle(hConnect);
pInternetCloseHandle(hOpen);
}
PopulateHeaders(hRequest);
dwFlags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA;
pInternetSetOption (hRequest,
INTERNET_OPTION_SECURITY_FLAGS, &dwFlags, sizeof (dwFlags) );
if( ! pHttpSendRequest(hRequest, NULL, 0,
bstrPostData.GetBuffer(postDataLength), postDataLength) )
{
bstrPostData.ReleaseBuffer();
DWORD dwError = GetLastError();
DWORD dwFlags;
DWORD dwBuffLen = sizeof(dwFlags);
pInternetCloseHandle(hRequest);
pInternetCloseHandle(hConnect);
pInternetCloseHandle(hOpen);
}
bstrPostData.ReleaseBuffer();
....
pInternetCloseHandle(hRequest);
pInternetCloseHandle(hConnect);
pInternetCloseHandle(hOpen);
Thanks for your help.
When my application runs, the first HttpSendRequest is made from a network
that does not have access to the PAC file URL. This is successful.
After that the VPN tunnel is established, the PAC file URL is now valid;
however, the second HttpSendRequest fails with 12007. The PAC file does not
seem to get downloaded.
I released all the handles between the two requests, yet the second request
always fails. Any idea?
IE version is 6.0.2900. The requests are HTTPS (both)
Code snippet.
hOpen = pInternetOpen("MyApp", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (dwTimeout > 0)
{
pInternetSetOption(hOpen, INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeout,
sizeof(DWORD));
pInternetSetOption(hOpen, INTERNET_OPTION_SEND_TIMEOUT, &dwTimeout,
sizeof(DWORD));
}
DWORD dw = 20;
pInternetSetOption(hOpen, INTERNET_OPTION_CONNECT_RETRIES, &dw,
sizeof(DWORD));
hConnect = pInternetConnect(hOpen, urlInfo.lpszHostName, urlInfo.nPort, "",
"", INTERNET_SERVICE_HTTP, 0, 0);
CString bstrActionVerb = GET;
if (postDataLength > 0)
{
bstrActionVerb = POST;
}
char szAccept[] = "*/*";
LPSTR AcceptTypes[2]={0};
AcceptTypes[0]=szAccept;
DWORD dwFlag;
if (urlInfo.nScheme == INTERNET_SCHEME_HTTPS)
{
dwFlag = INTERNET_FLAG_SECURE |
INTERNET_FLAG_KEEP_CONNECTION |
INTERNET_FLAG_IGNORE_CERT_CN_INVALID |
INTERNET_FLAG_IGNORE_CERT_DATE_INVALID |
INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS |
INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP;
}
else
{
dwFlag = INTERNET_FLAG_KEEP_CONNECTION;
}
hRequest = pHttpOpenRequest(hConnect, bstrActionVerb,
urlInfo.lpszUrlPath,
HTTP_VERSION, "", (LPCSTR*) AcceptTypes,
dwFlag ,0);
if (hRequest == NULL) {
DWORD dwErr = GetLastError();
pInternetCloseHandle(hConnect);
pInternetCloseHandle(hOpen);
}
PopulateHeaders(hRequest);
dwFlags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA;
pInternetSetOption (hRequest,
INTERNET_OPTION_SECURITY_FLAGS, &dwFlags, sizeof (dwFlags) );
if( ! pHttpSendRequest(hRequest, NULL, 0,
bstrPostData.GetBuffer(postDataLength), postDataLength) )
{
bstrPostData.ReleaseBuffer();
DWORD dwError = GetLastError();
DWORD dwFlags;
DWORD dwBuffLen = sizeof(dwFlags);
pInternetCloseHandle(hRequest);
pInternetCloseHandle(hConnect);
pInternetCloseHandle(hOpen);
}
bstrPostData.ReleaseBuffer();
....
pInternetCloseHandle(hRequest);
pInternetCloseHandle(hConnect);
pInternetCloseHandle(hOpen);
Thanks for your help.