Count of http requests

Using the YSlow Firebug extension Yahoo Developer Network ,
I can see how many HTTP requests a page made. For example,
Slashdot Poll 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 =
r =

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

body_io =

unzipped_body =
puts “Count of characters in page = #{unzipped_body.size}”

Jeff Fry