require 'rubygems' require 'eventmachine' require '../lib/em-http' urls = ARGV if urls.size < 1 puts "Usage: #{$0} <...>" exit end pending = urls.size EM.run do urls.each do |url| http = EM::HttpRequest.new(url).get http.callback { puts "#{url}\n#{http.response_header.status} - #{http.response.length} bytes\n" puts http.response pending -= 1 EM.stop if pending < 1 } http.errback { puts "#{url}\n" + http.error pending -= 1 EM.stop if pending < 1 } end end