I bought the bundle and I’m happy with it.
But now I’m trying to use the PercentDone event. I’m doing a HTTP PUT with picture data in the body (http.LoadBodyFromFile) and it’s working fine.
However, the data can be quite heavy (a few Mb) and I’d like to show a progress bar.
I tried to follow the doc, creating a subclass of chilkat.http: myHTTP, with a method: PercentDone
Sub PercentDone(pct_Done As Int32, abort As Boolean) System.DebugLog(CurrentMethodName + " " + str(pct_Done)) End Sub
Here’s a summary of the http request method:
Dim ckHttp As new myHttp ‘ subclass of Chilkat.Htpp Dim ckHttpReq As new Chilkat.HttpRequest Dim ckHttpResp As Chilkat.HttpResponse
ckHttp.OAuth1 = True ‘here the others ckHttp.OAuthxxx parameters
ckHttpReq.HttpVerb = "PUT" ‘ Test file ils loaded If ckHttpReq.LoadBodyFromFile(pic.NativePath) then ckHttp.PercentDoneScale = 100 ckHttpResp = ckHttp.PostUrlEncoded(baseURL, ckHttpReq)
‘ here comes the processing of the http response
This is working fine but the PercentDone method is never called, even for large files.
I guess I’m missing something.
One problem with the Chilkat HTTP API is that each method call both sends the request and gets the response. The PercentDone event can track either the sending of the request, or the retrieval of the response. (If the response is to be PercentDone tracked, then it is only possible for HTTP responses containing a Content-Length. It's not possible for the "chunked" transfer encoding.)
That being said.. Chilkat decides which side of the HTTP operation is to be tracked based on the method call and/or the HTTP verb. For GET requests, it is the response that is PercentDone tracked. For POST's, it is typically the response that is tracked, except if it is a multipart post that is typical of an upload, where the amount of data in the request is large. For PUT requests, it is the sending of the request that is tracked.
In your code sample above, you are setting the HttpRequest.HttpVerb = "PUT", but you are calling PostUrlEncoded. In that case, the verb actually used will be "POST" and therefore it's the response that is PercentDone tracked, not the request.
Instead of calling PostUrlEncoded, call a method such as SynchronousRequest, PutBinary, or PutText.
I should note that Chilkat is currently working on a REST API that is much better designed, and provides a finer-grained API where the sending of the request and the receiving of the response are broken into separate methods. (There will also be Auth classes for Google, Amazon AWS, Azure Storage, and Azure AD.) But please don't ask for pre-releases yet..