Question

I tried to use WinHTTP Request to retrieve a webpage (HTTPS website) in VB.Net and for some reason it was only returning the partial HTML, is there any length restriction on the number of characters it could take? If so, can I get the content after, say, 10000th character?

The relevant code is here:

         oRequest = New WinHttp.WinHttpRequest            
            oRequest.Open("GET", sQueryURL, False)            
            oRequest.SetTimeouts(0, 600000, 0, 0)
            oRequest.Send()
            If oRequest.Status = "200" Then                
                Debug.Print(oRequest.ResponseText)
            Else

            End If

Was it helpful?

Solution

It's been a while since I've used WinHttpRequest, but I believe as soon as you read ResponseText, WinHttpRequest will abandon processing the response. Since you're diving right in reading the response I'd guess the full response hasn't arrived by the time you print ResponseText!

I think you have 2 options to try:

  1. Use WinHttpRequest.WaitForResponse() to wait for the entire response to be ready
  2. Use WinHttpRequest.ResponseStream to process the response in chunks (you'll need to convert the chunks from bytes to readable text)

I can't tell if you're using VB.Net, but if you are: consider using System.Web.HttpRequest. The interface is pretty much the same and you will have an easier time finding working examples and advice.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top