fabrizio
2004-09-29 08:33:48 UTC
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
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