EDIT: This question has changed as I have waited for an answer and done external research. I’ve rephrased the title, and the question is really that I’m looking for an alternative to MSXML2 (even if it means writing socket code).
The original body of the question is left here for reference and to help people in the future who are doing similar searches.
In VBA, using MSXML2 object, is there a way to get access to the
streaming data while readyState = 3, as it comes in?I am using the
OnReadyStateChangemethod, but I don’t seem to have
access toresponseTextuntil readyState is 4. When readyState is 3,
there doesn’t seem to be any data.Is there any way in VBA to have access to the HTTP streaming response
while it is coming in? Another method I could use in MSXML2, or a
better (free, distributable) object to use to make “AJAX” calls?More information: If I try to read
responseStream(or
responseText), the error description is:
The data necessary to complete this operation is not yet available.Second edit, more information: This link basically says that this is
expected behavior in theINTERACTIVE(3) state:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms753800(v=vs.85).aspx
So I am definitely looking for the “is there any alternative?” answer.
This is an old bit of code I wrote to reads chunks using the WinInet API, its not asynchronous but it exposes a read buffer after every 512 bytes (I added a Debug.Print “READ ” & lngTotalBytesRead to illustrate) – http://pastebin.com/6uMhkBUF
From what I can remember it worked ok but I’ve had to un-mangle it a bit.
You will need to remove the calls to
App.inHTTPGetUAString(This was VB6 originally) so justHTTPGetUAString = "MyThing"or the like.If (lngContentLen = 0&) Then lngContentLen = (BUFF_LEN * DUMMY_BUFF_MULTIPLIER)is a left-over; you can delete the line. (Subsequently if lngContentLen is zero the size is unknown in advance)