Hi,

I've just started using the wininet APIs from VB. Basically I just want to
read files from other sites. The code below seems to be fine for the majority
of cases. It just sends an http request, checks the response headers for
status denied and then resends with Basic WWW-Authentication if required.
When trying to access a HTTPS site (which requires basic authentication)
the code hangs at the HttpSendRequest statement on the first pass. Is there
something else I need to do for HTTPS? Any ideas gratefully received!

Thanks,
Simon

Basically the code's something like this (I've let out error checks here),
for HTTPS the CrackUrl function returns INTERNET_DEFAULT_HTTPS_PORT.

hOpen = InternetOpen(USERAGENT, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString,
vbNullString, 0)

' Split Url into its component parts (this is just a wrapper around the API
function InternetCrackUrl)
CrackUrl sUrl, sServer, sPath, lPort, ""

' Open connection to the server
hConnect = InternetConnect(hOpen, sServer, lPort, vbNullString, vbNullString,
INTERNET_SERVICE_HTTP, 0, 0)

' Open Request
hRequest = HttpOpenRequest(hConnect, "GET", sPath, vbNullString, vbNullString,
0, INTERNET_FLAG_RELOAD Or INTERNET_FLAG_KEEP_CONNECTION, 0)

SendRequest:
' Send
lReturn = HttpSendRequest(hRequest, vbNullString, 0, vbNullString, 0)

' Check the response header status
lReturn = HttpQueryInfo(hRequest, HTTP_QUERY_FLAG_NUMBER Or HTTP_QUERY_STATUS_CODE,
lStatus, lStatusSize, 0)

' See if access was denied
If lStatus = HTTP_STATUS_DENIED Then
' Set user name and password
InternetSetOption hRequest, INTERNET_OPTION_USERNAME, sUserName, Len(sUserName)
+ 1
InternetSetOption hRequest, INTERNET_OPTION_PASSWORD, sPassword, Len(sPassword)
+ 1

' Retry
Goto SendRequest
End If

' Read File if everything went OK
........