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
a) Which function is returning this code?
b) From the very first glance, passing INTERNET_DEFAULT_HTTP_PORT for
a host with port 8000 seems plain wrong according to the msdn docs.
Regards
Oliver
a) The function was WinHttpSendRequest.
b) Thank you very much! This solved the problem. I removed the :8000
suffix from the hostname, and passed the port 8000 as part of the
WinHttpConnect function, and it worked. The corrected corrected code
is:
USES_CONVERSION;
const char* hostname; // name of the host (without query
string)
const char* options; // query string to follow the host
name
DWORD myerrno;
// this did not work ----> hostname = "64.131.242.23:8000";
// the following does work:
hostname = " "64.131.242.23";
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), 8000, 0);