RobertD
2010-10-22 21:37:26 UTC
Dear Anyone who can help:
I am using the following code to do an HTTP GET, and it works fine
almost everywhere. However, for one specific URL it fails with an
error 87. Can anyone explain why that would be, and how I solve the
problem?
USES_CONVERSION;
const char* hostname; // name of the host (without query string)
const char* options; // query string to follow the host name
DWORD myerrno;
hostname = "64.131.242.23:8000";
options = "safetogo/login.jsp";
BOOL bResults = FALSE;
HINTERNET hSession = NULL,
hConnect = NULL,
hRequest = NULL;
hSession = WinHttpOpen( L"MySite HTTP/1.0",
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS, 0);
if (!hSession)
{
return false;
}
hConnect = WinHttpConnect( hSession, T2W(hostname),
INTERNET_DEFAULT_HTTP_PORT, 0);
if (!hConnect)
{
return false;
}
hRequest = WinHttpOpenRequest( hConnect, L"GET",
T2W(options),
NULL, WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
WINHTTP_FLAG_REFRESH);
if (!hRequest)
{
return false;
}
// Send a request.
bResults = WinHttpSendRequest( hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS,
0,
WINHTTP_NO_REQUEST_DATA, 0, 0,
0);
if (!bResults)
{
myerrno = GetLastError();
return false;
}
// End the request.
if (bResults)
bResults = WinHttpReceiveResponse( hRequest, NULL);
Regards and thanks!
RobertD
I am using the following code to do an HTTP GET, and it works fine
almost everywhere. However, for one specific URL it fails with an
error 87. Can anyone explain why that would be, and how I solve the
problem?
USES_CONVERSION;
const char* hostname; // name of the host (without query string)
const char* options; // query string to follow the host name
DWORD myerrno;
hostname = "64.131.242.23:8000";
options = "safetogo/login.jsp";
BOOL bResults = FALSE;
HINTERNET hSession = NULL,
hConnect = NULL,
hRequest = NULL;
hSession = WinHttpOpen( L"MySite HTTP/1.0",
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS, 0);
if (!hSession)
{
return false;
}
hConnect = WinHttpConnect( hSession, T2W(hostname),
INTERNET_DEFAULT_HTTP_PORT, 0);
if (!hConnect)
{
return false;
}
hRequest = WinHttpOpenRequest( hConnect, L"GET",
T2W(options),
NULL, WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
WINHTTP_FLAG_REFRESH);
if (!hRequest)
{
return false;
}
// Send a request.
bResults = WinHttpSendRequest( hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS,
0,
WINHTTP_NO_REQUEST_DATA, 0, 0,
0);
if (!bResults)
{
myerrno = GetLastError();
return false;
}
// End the request.
if (bResults)
bResults = WinHttpReceiveResponse( hRequest, NULL);
Regards and thanks!
RobertD