# Net::HTTP.check\_response very slow?

**URL:** <https://www.ruby-forum.com/t/net-http-check-response-very-slow/131287>\
**Category:** Ruby\
**Created:** [March 7, 2008, 5:39pm UTC](https://www.ruby-forum.com/t/net-http-check-response-very-slow/131287 "2008-03-07T17:39:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [March 7, 2008, 5:39pm UTC](https://www.ruby-forum.com/t/net-http-check-response-very-slow/131287/1 "2008-03-07T17:39:21Z")

</div>

I am working on something that uses Net::HTTP to obtain the final url  
from a redirected url and, well, it seems really slow. I’m using ruby  
1.8.6-p111 and have verified this behavior on OS X, Ubuntu Linux, and  
Windows XP.

A sample app is attached and here were my results, comparing the pure  
ruby approach to one shelling out to curl…

Tim@thinktank: tmp =\> time ./url\_check.rb  
[http://ia600302.us.archive.org/33/items/gd90-02-26.sbd.shakedown.451.sbeok.shnf/gd90-02-26d3t05.mp3](http://ia600302.us.archive.org/33/items/gd90-02-26.sbd.shakedown.451.sbeok.shnf/gd90-02-26d3t05.mp3)

real 0m32.659s  
user 0m4.423s  
sys 0m3.168s

Tim@thinktank: tmp =\> time ./url\_check.rb --use-curl  
[http://ia600302.us.archive.org/33/items/gd90-02-26.sbd.shakedown.451.sbeok.shnf/gd90-02-26d3t05.mp3](http://ia600302.us.archive.org/33/items/gd90-02-26.sbd.shakedown.451.sbeok.shnf/gd90-02-26d3t05.mp3)

real 0m0.754s  
user 0m0.030s  
sys 0m0.022s

I expected the pure ruby approach to be slower but these results seem  
out of line just for a series of http response checks… Any ideas?

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [March 7, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/net-http-check-response-very-slow/131287/2 "2008-03-07T17:50:52Z")

</div>

On Sat, Mar 08, 2008 at 01:39:13AM +0900, Tim F. wrote:

> real 0m32.659s  
> user 0m4.423s  
> sys 0m3.168s

You are doing a full HTTP GET in this request and it is downloading the  
mp3.  
Try:

response = Net::HTTP.start(‘[ia340903.us.archive.org](http://ia340903.us.archive.org)’) do |http|  
http.head(‘/0/items/gd90-02-26.sbd.shakedown.451.sbeok.shnf/gd90-02-26d3t05\_vbr.mp3’)  
end

> Tim@thinktank: tmp =\> time ./url\_check.rb --use-curl  
> [http://ia340903.us.archive.org/0/items/gd90-02-26.sbd.shakedown.451.sbeok.shnf/gd90-02-26d3t05\_vbr.mp3](http://ia340903.us.archive.org/0/items/gd90-02-26.sbd.shakedown.451.sbeok.shnf/gd90-02-26d3t05_vbr.mp3)
> 
> real 0m0.754s  
> user 0m0.030s  
> sys 0m0.022s

You are using curl’s -I option here which odes an HTTP HEAD and only  
gets the  
headers of the response, and does retrieve the

> I expected the pure ruby approach to be slower but these results seem  
> out of line just for a series of http response checks… Any ideas?
> 
> Cheers,  
> Tim

enjoy,

-jeremy

---

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [March 7, 2008, 7:07pm UTC](https://www.ruby-forum.com/t/net-http-check-response-very-slow/131287/3 "2008-03-07T19:07:53Z")

</div>

Jeremy H. wrote:

> You are doing a full HTTP GET in this request and it is downloading the  
> mp3.

Ah! That explains it… 🙂

Thanks much!  
Tim
