Discussion:
Invalid URL Checking.
(too old to reply)
Rasheed
2007-07-29 12:19:52 UTC
Permalink
hi All,
i am facing one problem i.e for an Invalid URL i am getting the non
zero handle values. here is my code for your understanding.
This is my Invalid URL:
http://www.google.co.in/sea123rch?hl=en&q=flow123ers&meta=

but when I am executing below code I am getting the
hConnect,hRequest,bResults value.

I know that I have to get the value of hConnect because there I am
sending the correct server name "www.google.co.in" value but in the
case of WinHttpOpenRequest(), has to give the
"ERROR_WINHTTP_INVALID_URL" error becuase i am giving wrong
objectname.
so I am still confuse how I am getting the non Zero value for
hRequest.
So can any body help me please.

hSession = WinHttpOpen(GetClientAgentName(),
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS, 0);

if( hSession )
{
hConnect = WinHttpConnect( hSession, pollAddress,
refPolicy.m_dwPort /*INTERNET_DEFAULT_HTTPS_PORT*/, 0);

//pollAddress is in this case : www.google.co.in
}


if( hConnect )
{
hRequest = WinHttpOpenRequest( hConnect,
refPolicy.m_strVerb.c_str(),
pUrl, /// "/sea123rch?hl=en&q=flow123ers&meta="
NULL,
WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
WINHTTP_FLAG_BYPASS_PROXY_CACHE );
}

if( hRequest )
{
WinHttpSetTimeouts(hRequest, pollingOptions.m_dwTimeout,
pollingOptions.m_dwTimeout,
pollingOptions.m_dwTimeout,
pollingOptions.m_dwTimeout);

bResults = WinHttpSendRequest( hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
WINHTTP_NO_REQUEST_DATA, 0,
0, 0 );
}


if( bResults )
{
bResults = WinHttpReceiveResponse( hRequest, NULL );
}


Regards,
Rs.
Rasheed
2007-07-30 11:25:48 UTC
Permalink
//i have rewritten above code for porviding some more infor like port
number
Hi All,

i am facing one problem i.e for an Invalid URL i am getting the
non
zero handle values(for WinHttpOpenRequest,WinHttpSendRequest handles).
here is my code for your understanding.
This is my Invalid URL:
http://www.google.co.in/sea123rch?hl=en&q=flow123ers&meta=

but when I execute my code I was getting the
hConnect,hRequest,bResults value.


I know that I have to get non Zero value for hConnect because i have
given proper server name which is "www.google.co.in" but in the
case of WinHttpOpenRequest(), has to give the
"ERROR_WINHTTP_INVALID_URL" error becuase i have given wrong
objectname.
so I am still confuse how I am getting the non Zero value for
hRequest, bResults.
So can any body kindly help me how to find/Check the Valid URLs and
Invlid URLs.


hSession = WinHttpOpen(GetClientAgentName(),
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS, 0);


if( hSession )
{
hConnect = WinHttpConnect( hSession, pollAddress, //
pollAddress is in this case : www.google.co.in
refPolicy.m_dwPort/* "80 is
the PORT NUM" *//*INTERNET_DEFAULT_HTTPS_PORT*/, 0);
}


if( hConnect )
{
hRequest = WinHttpOpenRequest( hConnect,
refPolicy.m_strVerb.c_str(), //
{"GET"}
pUrl, /// "/sea123rch?
hl=en&q=flow123ers&meta="
NULL,
WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
WINHTTP_FLAG_BYPASS_PROXY_CACHE );
}


if( hRequest )
{
WinHttpSetTimeouts(hRequest, pollingOptions.m_dwTimeout,
pollingOptions.m_dwTimeout,
pollingOptions.m_dwTimeout,
pollingOptions.m_dwTimeout);

bResults = WinHttpSendRequest( hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
WINHTTP_NO_REQUEST_DATA, 0,
0, 0 );
}


if( bResults )
{
bResults = WinHttpReceiveResponse( hRequest, NULL );
}


Regards,
Rs.

Loading...