There are two ways you can handle buffer updates:
The method receives a lnBufferReads parameter which determines what type of request is being made:
0 - HTTP Header is sent
-1 - The HTTP request was completed or cancelled. (lHttpCancelDownload is set if cancelled)
Any other value greater than 0 is the number of times OnHTTPBufferUpdate was called in which case you can check the other parameters for the current download size and current chunk of data.
If you want things like Cancel buttons you will need to use DOEVENTS in the event code to allow the click events to fire. even so the responsiveness of the button may not be very good due to VFP's limited concurrent processing capabilities.
We also suggest that you increase your buffer size so that this event doesn't fire so frequently. Increasing nHTTPWorkBufferSize on the Http instance can significantly improve the performance of HTTP operations.
DO wwHTTP loHttp = CREATEOBJECT("wwHttp") *** Object that will handle the event. This could be a form *** or any other object instance on which you implement *** the OnHttpBufferUpdate event handler code loSink = CREATEOBJECT("HttpEventSink") *** Bind event from wwHttp to the event handling object BINDEVENT(loHTTP,"OnHttpBufferUpdate",loSink,"OnHttpBufferUpdate") *** Make the HTTP call - lcHTML is set but output is not used *** the output written by this example is written from the *** event handler as data is retrieved lcHTML = loHttp.HttpGet("http://www.microsoft.com") RETURN *** If you have a class instance - a Form for example *** you can use that class as the Event sink and simply *** add the method below to it DEFINE CLASS HttpEventSink as Custom FUNCTION OnHttpBufferUpdate LPARAMETERS lnbytes,lnbufferreads,lccurrentchunk, loHttp DO CASE *** 0 - Http Header CASE lnBufferReads = 0 lcHttpHeader = lcCurrentChunk *** -1 - done or cancelled or failed CASE lnBufferReads = -1 * done or cancelled IF loHttp.lhttpcanceldownload ? "Cancelled" ELSE ? "---" ? "Completed..." ENDIF *** anything else - data has been read CASE lnBufferReads > 0 WAIT WINDOW TRANSFORM(lnBytes,"9,999,999") + " of " + TRANSFORM(loHTTP.nContentSize,"9,999,999") + " bytes" NOWAIT ENDCASE *** Dump data incrementally ? lcCurrentChunk ENDDEFINE