Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WinHttpSendRequest returns error 87 only on one site

2,067 views
Skip to first unread message

RobertD

unread,
Oct 22, 2010, 5:37:26 PM10/22/10
to
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

OliverM

unread,
Oct 24, 2010, 2:39:58 PM10/24/10
to
Error code 87 is ERROR_INVALID_PASSWORD. That sounds strange - are you
sure?

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

RobertD

unread,
Oct 25, 2010, 2:44:35 PM10/25/10
to

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);

0 new messages