# Count of http requests

**URL:** <https://www.ruby-forum.com/t/count-of-http-requests/116161>\
**Category:** Ruby\
**Created:** [October 3, 2007, 1:46am UTC](https://www.ruby-forum.com/t/count-of-http-requests/116161 "2007-10-03T01:46:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bb73d2/32.png) [@jfry](https://www.ruby-forum.com/u/jfry)\
**Post date:** [October 3, 2007, 1:46am UTC](https://www.ruby-forum.com/t/count-of-http-requests/116161/1 "2007-10-03T01:46:07Z")

</div>

Using the YSlow Firebug extension [Yahoo Developer Network](http://developer.yahoo.com/yslow/) ,  
I can see how many HTTP requests a page made. For example,  
[Slashdot Poll](http://slashdot.org/pollBooth.pl) shows:

This page has 7 external JavaScript files.  
This page has 5 external StyleSheets.  
This page has 18 CSS background images.

I’m wondering how I can use Net::HTTP (and or other Ruby libs) to  
capture this information. I’m starting with a script that can tell me  
the header info and size of the page (below):

require ‘net/http’

a = String.new  
r = String.new

Net::HTTP.start(‘[slashdot.org](http://slashdot.org)’) do |http|  
response = http.get(‘/pollBooth.pl’)  
puts “Code = #{response.code}”  
puts “Message = #{response.message}”  
response.each {|key, val| printf “%-14s = %-40.40s\n”, key, val }  
a = response.body  
r = response  
end

body\_io = StringIO.new(r.body)

unzipped\_body = body\_io.read()  
puts “Count of characters in page = #{unzipped\_body.size}”

Thanks!  
Jeff Fry
