0

Is there a way to find out how much of a GET request has been received? I can't do Len(.ResponseBody) until it's complete, so that's not possible.

Hao Zhang
  • 147
  • 9

1 Answers1

0

I was researching how you could bind to IWinHttpRequestEvents. The OnResponseDataAvailable event is exactly what you need. It would give you the data as it came in. Then, you could handle it however you like.

Unfortunately, trying to bind to that event interface causes VBScript to crash with a C0000005 GPF. I also found a reference to it crashing in a different language. So, I can't say whether this would work in VBA or VB6 or any other language. Details are discussed in following question.

WScript.CreateObject crashes Windows Scripting Host when event handler prefix is specified for WinHTTPRequest


The alternative is to switch to Msxml2.XMLHTTP or Msxml2.ServerXMLHTTP. These objects come with a property named readyState that will give you some idea of what is happening to the download. It won't give you the current number of bytes downloaded, but it's something.

Additionally, there you can trap the onReadyStateChange event, which will let you know when the readyState on the object has changed. Microsoft has even provided sample code for trapping the event.

Community
  • 1
  • 1
jveazey
  • 5,398
  • 1
  • 29
  • 44