Archived Forum Post

Index of archived forum posts

Question:

Http File Download Progress Events

May 07 '14 at 13:41

I'm probably missing something simple, but my HttpProgress event handler is only receiving 100% done events. I have a 200ms heartbeat and a 500mb test file. Other events are firing just fine. Am I missing something or does this event only fire on 100% complete?

http.put_EventCallbackObject(&httpProgress);

http.put_HeartbeatMs(200);

bool result = http.Download(uri.c_str(), saveTo.c_str());

//Callback Handler

void CHttpProgress::PercentDone( int pctDone, bool *abort ) { int p = pctDone; }

Thanks, Jay


Answer

If the HTTP response is chunked, then it is impossible to monitor progress as a percentage completed. In a chunked response (see http://www.codeproject.com/Articles/648526/All-about-http-chunked-responses ) there is no Content-Length header. This means the receiver has no way of knowing how much data is forthcoming. The client receives the HTTP response chunk-by-chunk until it receives a final 0-length chunk indicating that the response is complete.

Here is an HttpChunked event callback that will occur for chunked responses. (I suspect there is also a ProgressInfo event callback to indicate the chunked response as well.)


Answer

Hmmm I saw that in the api documentation and I don't believe the response is chunked as there is a Content-Length header. Here is the anonymized request/response from the session log. I also checked the request/response with Firebug to see if Transfer-Encoding is present and it shows the same information as the session log below. Any help/info is appreciated.

---- Sending ---- GET /test/test.iso?sv=2013-08-15&sr=b&sig=of2piUGR5d060HRrfI0AuvntbSY5E8VCO%2FP%2BN2KuDaU%3D&st=2014-05-06T17%3A46%3A10Z&se=2014-05-06T18%3A51%3A10Z&sp=r HTTP/1.1

Accept: /

Accept-Encoding: gzip

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Accept-Language: en-us,en;q=0.5

User-Agent: Chilkat/1.0.0 (+http://www.chilkatsoft.com/ChilkatHttpUA.asp)

Host: ***********.blob.core.windows.net

Connection: Keep-Alive

---- Received ----

HTTP/1.1 200 OK

Content-Length: 617756672

Content-Type: application/octet-stream

Last-Modified: Mon, 05 May 2014 18:48:50 GMT

Accept-Ranges: bytes

ETag: "0x8D136A9CA72734F"

Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0

x-ms-request-id: a4f02a5e-edb6-4ac9-9154-7ddb0a00dd7e

-ms-version: 2013-08-15

x-ms-lease-status: unlocked

x-ms-lease-state: available

x-ms-blob-type: BlockBlob

x-ms-copy-id: 5d0badd7-969e-47f7-b572-41381f479701

x-ms-copy-source: https://*******.blob.core.windows.net/test/test.iso

x-ms-copy-status: success

x-ms-copy-progress: 617756672/617756672

x-ms-copy-completion-time: Mon, 05 May 2014 18:48:50 GMT

Date: Tue, 06 May 2014 17:55:31 GMT


Answer

Thanks Fat Ben Affleck. ;)

(Love the name by the way..)

Anyway, check the LastErrorText and make sure you're at the latest version. If not, then re-try with the latest version. If the problem still occurs, post the contents of the LastErrorText. (It would be a good idea to use verbose logging too -- by setting the VerboseLogging property = true)


Answer

Thanks for the help. Updating to version 9.5 solved the issue.