Discussion:
HttpQueryInfoError
(too old to reply)
fabrizio
2004-09-29 08:33:48 UTC
Permalink
Hi All, I'm attempting to download a file from the internet using vb6
I need to get thru a firewall/proxy and so am using the following
code:
'------------------------------------------------------------------------------------------------------------------------------------------------
hOpenHandle = InternetOpen(App.Title, INTERNET_OPEN_TYPE_PRECONFIG,
vbNullString, vbNullString, 0)

hConnectHandle = InternetConnect(hOpenHandle, strServer, iPorta,
vbNullString, vbNullString, INTERNET_SERVICE_HTTP, 0, 0)

hResourceHandle = HttpOpenRequest(hConnectHandle, "GET", sUrl,
vbNullString, vbNullString, 0, INTERNET_FLAG_DONT_CACHE Or
INTERNET_FLAG_KEEP_CONNECTION, 0)

If hResourceHandle > 0 Then

resend:

If HttpSendRequest(hResourceHandle, vbNullString, 0, Null, 0) > 0
Then

If HttpQueryInfo(hResourceHandle, HTTP_QUERY_FLAG_NUMBER Or
HTTP_QUERY_STATUS_CODE, lStatus, Len(lStatus), 0) > 0 Then

If lStatus = HTTP_STATUS_PROXY_AUTH_REQ Then

'Set error code
If hResourceHandle Then
dwErrorCode = 0
Else
dwErrorCode = Err.LastDllError
End If

'Ask for proxy login
dwError = InternetErrorDlg(lngHandle, hResourceHandle,
dwErrorCode, FLAGS_ERROR_UI_FILTER_FOR_ERRORS Or
FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS Or
FLAGS_ERROR_UI_FLAGS_GENERATE_DATA, vbNullString)

'Resend request with proxy authorization
If (dwError = ERROR_INTERNET_FORCE_RETRY) Then
GoTo resend
End If

End If
'----------------------------------------------------------------------------------------------------------------------------------------------------------
I have followed microsoft's proxy code examples and can get most of
my code to work once. On the first run I get the expected error code
of 407

second time i get either error 502 (invalid gateway) or 504 (gateway
timeout)
please help me.
thanks
Brian Combs
2004-10-08 19:49:29 UTC
Permalink
Hello
502 and 504 errors are valid errors from the web server to your request. It
sounds like you did auth to the proxy and then the web server had an error
while processing your request. Most 502 or 504 erros come from CGI
applications on the web server. You can also test using the following
article:
259100 SAMPLE: Vbhttp.exe Demonstrates How to Use HTTP WinInet APIs in
Visual
http://support.microsoft.com/?id=259100

Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: ***@yahoo.it (fabrizio)
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| Subject: HttpQueryInfoError
| Date: 29 Sep 2004 01:33:48 -0700
| Organization: http://groups.google.com
| Lines: 54
| Message-ID: <***@posting.google.com>
| NNTP-Posting-Host: 62.241.2.2
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1096446828 26104 127.0.0.1 (29 Sep 2004
08:33:48 GMT)
| X-Complaints-To: groups-***@google.com
| NNTP-Posting-Date: Wed, 29 Sep 2004 08:33:48 +0000 (UTC)
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.s
ul.t-online.de!t-online.de!fr.ip.ndsoftware.net!proxad.net!postnews1.google.
com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.inetsdk.programming.wininet:11377
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
| Hi All, I'm attempting to download a file from the internet using vb6
| I need to get thru a firewall/proxy and so am using the following
| code:
|
'---------------------------------------------------------------------------
---------------------------------------------------------------------
| hOpenHandle = InternetOpen(App.Title, INTERNET_OPEN_TYPE_PRECONFIG,
| vbNullString, vbNullString, 0)
|
| hConnectHandle = InternetConnect(hOpenHandle, strServer, iPorta,
| vbNullString, vbNullString, INTERNET_SERVICE_HTTP, 0, 0)
|
| hResourceHandle = HttpOpenRequest(hConnectHandle, "GET", sUrl,
| vbNullString, vbNullString, 0, INTERNET_FLAG_DONT_CACHE Or
| INTERNET_FLAG_KEEP_CONNECTION, 0)
|
| If hResourceHandle > 0 Then
|
| resend:
|
| If HttpSendRequest(hResourceHandle, vbNullString, 0, Null, 0) > 0
| Then
|
| If HttpQueryInfo(hResourceHandle, HTTP_QUERY_FLAG_NUMBER Or
| HTTP_QUERY_STATUS_CODE, lStatus, Len(lStatus), 0) > 0 Then
|
| If lStatus = HTTP_STATUS_PROXY_AUTH_REQ Then
|
| 'Set error code
| If hResourceHandle Then
| dwErrorCode = 0
| Else
| dwErrorCode = Err.LastDllError
| End If
|
| 'Ask for proxy login
| dwError = InternetErrorDlg(lngHandle, hResourceHandle,
| dwErrorCode, FLAGS_ERROR_UI_FILTER_FOR_ERRORS Or
| FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS Or
| FLAGS_ERROR_UI_FLAGS_GENERATE_DATA, vbNullString)
|
| 'Resend request with proxy authorization
| If (dwError = ERROR_INTERNET_FORCE_RETRY) Then
| GoTo resend
| End If
|
| End If
|
'---------------------------------------------------------------------------
----------------------------------------------------------------------------
---
| I have followed microsoft's proxy code examples and can get most of
| my code to work once. On the first run I get the expected error code
| of 407
|
| second time i get either error 502 (invalid gateway) or 504 (gateway
| timeout)
| please help me.
| thanks
|
fabrizio
2004-10-11 13:03:47 UTC
Permalink
Post by Brian Combs
Hello
502 and 504 errors are valid errors from the web server to your request. It
sounds like you did auth to the proxy and then the web server had an error
while processing your request. Most 502 or 504 erros come from CGI
applications on the web server. You can also test using the following
259100 SAMPLE: Vbhttp.exe Demonstrates How to Use HTTP WinInet APIs in
Visual
http://support.microsoft.com/?id=259100
Thanks, i found the problem, it was in this function

InternetConnect(hOpenHandle, strServer, INTERNET_DEFAULT_HTTP_PORT,
vbNullString, vbNullString, INTERNET_SERVICE_HTTP, 0, 0)

in third parameter (proxy port) i had my proxy port number(8080 read
from registry) instead of INTERNET_DEFAULT_HTTP_PORT.

now i've to try it with differents proxy/firewalls.
fabrizio
2004-10-12 09:20:43 UTC
Permalink
Post by fabrizio
Post by Brian Combs
Hello
502 and 504 errors are valid errors from the web server to your request. It
sounds like you did auth to the proxy and then the web server had an error
while processing your request. Most 502 or 504 erros come from CGI
applications on the web server. You can also test using the following
259100 SAMPLE: Vbhttp.exe Demonstrates How to Use HTTP WinInet APIs in
Visual
http://support.microsoft.com/?id=259100
Thanks, i found the problem, it was in this function
InternetConnect(hOpenHandle, strServer, INTERNET_DEFAULT_HTTP_PORT,
vbNullString, vbNullString, INTERNET_SERVICE_HTTP, 0, 0)
in third parameter (proxy port) i had my proxy port number(8080 read
from registry) instead of INTERNET_DEFAULT_HTTP_PORT.
now i've to try it with differents proxy/firewalls.
HI Brian, now it work fine, but i dont understand why i have to set
(INTERNET_DEFAULT_HTTP_PORT=80) if the port for my proxy is 8080.

can u explain me?

thanks!

Loading...