Forum: Ruby Download progress

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel V. (Guest)
on 2009-04-29 09:48
(Received via mailing list)
Let's consider we're getting a long file through HTTP:

How to get a progress (percentage of done) of the download process? I
didn't find such API in Net::HTTP
Eric H. (Guest)
on 2009-04-29 10:57
(Received via mailing list)
On Apr 28, 2009, at 22:45, Daniel V. wrote:

> Let's consider we're getting a long file through HTTP:
>
> How to get a progress (percentage of done) of the download process? I
> didn't find such API in Net::HTTP

You can use Net::HTTP#request_get and Net::HTTPResponse#read_body:

$ ruby -rnet/http
h = Net::HTTP.new 'blog.segment7.net'
h.request_get '/' do |r| r.read_body do |s| p s.length end end
^D
751
184
1024
184
1024
184
[...]
$

There are probably other ways without #request_get
Robert H. (Guest)
on 2009-04-29 14:33
Cool, I also did not know that, but I wondered about this for a long
time.

Nice to see such snippets. :)
7stud -. (Guest)
on 2009-04-29 19:07
Marc H. wrote:
> Cool, I also did not know that, but I wondered about this for a long
> time.
>
> Nice to see such snippets. :)

I also put a note in the margin of my book about this one. :)
Mathspeedy (Guest)
on 2009-04-30 03:40
(Received via mailing list)
You could use the "progressbar" library ..
This topic is locked and can not be replied to.