# Download progress

**URL:** <https://www.ruby-forum.com/t/download-progress/166749>\
**Category:** Ruby\
**Created:** [April 29, 2009, 7:48am UTC](https://www.ruby-forum.com/t/download-progress/166749 "2009-04-29T07:48:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel304](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@daniel304](https://www.ruby-forum.com/u/daniel304)\
**Post date:** [April 29, 2009, 7:48am UTC](https://www.ruby-forum.com/t/download-progress/166749/1 "2009-04-29T07:48:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![daniel304](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@daniel304](https://www.ruby-forum.com/u/daniel304)\
**Post date:** [April 29, 2009, 8:57am UTC](https://www.ruby-forum.com/t/download-progress/166749/2 "2009-04-29T08:57:34Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![daniel304](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@daniel304](https://www.ruby-forum.com/u/daniel304)\
**Post date:** [April 29, 2009, 12:33pm UTC](https://www.ruby-forum.com/t/download-progress/166749/3 "2009-04-29T12:33:22Z")

</div>

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

Nice to see such snippets. 🙂

---

<div class="post-metadata">

**Author:** ![daniel304](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@daniel304](https://www.ruby-forum.com/u/daniel304)\
**Post date:** [April 30, 2009, 1:40am UTC](https://www.ruby-forum.com/t/download-progress/166749/4 "2009-04-30T01:40:23Z")

</div>

You could use the “progressbar” library …

---

<div class="post-metadata">

**Author:** ![daniel304](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@daniel304](https://www.ruby-forum.com/u/daniel304)\
**Post date:** [April 29, 2009, 5:07pm UTC](https://www.ruby-forum.com/t/download-progress/166749/5 "2009-04-29T17:07:34Z")

</div>

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. 🙂
