[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Download progress

Daniel Vartanov

4/29/2009 5:42:00 AM

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
4 Answers

Eric Hodel

4/29/2009 6:57:00 AM

0

On Apr 28, 2009, at 22:45, Daniel Vartanov 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

Marc Heiler

4/29/2009 10:33:00 AM

0

Cool, I also did not know that, but I wondered about this for a long
time.

Nice to see such snippets. :)
--
Posted via http://www.ruby-....

7stud --

4/29/2009 3:08:00 PM

0

Marc Heiler 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. :)

--
Posted via http://www.ruby-....

|||=[Mathspeedy]=||| |||=[Z3d0clan]=|||

4/29/2009 11:37:00 PM

0

You could use the "progressbar" library ..