Re: How can you make an async http request to download a file in chunks?



Thank you! This definitely helped, and I ended up getting it working. I
attached callbacks to both the got_chunk and got_headers events. I
posted my solution to stackoverflow:

http://stackoverflow.com/questions/14806981/using-gjs-how-can-you-make-an-async-http-request-to-download-a-file-in-chunks/14819550

I don't think the non-utf8 chars will be an issue here. The file I'm
downloading is a .tar.gz, but the got_chunk event passes in a
Soup.Buffer object instead of just a string, and in my tests it appears
to be handling it fine.

On 02/11/2013 02:08 AM, Alan Knowles wrote:
> The example looks good,
> 
> http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Soup.Message.html#expand
> 
> indicates there is a got_chunk signal of message, you might be able to
> hook into that to update the progress bar.
> 
> you might be lucky and be able to get the header  Content-Length,  and
> use the length of the response_body to show the percentage complete...,
> but Soap is a touch klunky when it comes to introspection..
> 
> I'm not sure about gjs, but handling of non-utf8 characters in seed can
> seriously mess up the engine, so be careful..
> 
> Regards
> Alan
> 
> On Monday, February 11, 2013 02:29 PM, Micah Lee wrote:
>> I just asked this question on stackoverflow, but hopefully somewhere
>> here could help too:
>>
>> http://stackoverflow.com/questions/14806981/using-gjs-how-can-you-make-an-async-http-request-to-download-a-file-in-chunks
>>
>> Basically, I'm trying to download a file and show the status of the
>> download in a Gtk.ProgressBar. Any help or example code is appreciated,
>> thanks!
>>
>>
>>
>> _______________________________________________
>> javascript-list mailing list
>> javascript-list gnome org
>> https://mail.gnome.org/mailman/listinfo/javascript-list
> 


-- 
Micah Lee
https://twitter.com/micahflee

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]