Sha256: e21d032c2d5aff44b2a51c5ed0699876fa6afbd7d91355ee19562bd76173f850

Contents?: true

Size: 558 Bytes

Versions: 15

Compression:

Stored size: 558 Bytes

Contents

require 'rubygems'
require 'eventmachine'
require '../lib/em-http'

urls = ARGV
if urls.size < 1
  puts "Usage: #{$0} <url> <url> <...>"
  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.errors.join("\n")

      pending -= 1
      EM.stop if pending < 1
    }
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
astro-em-http-request-0.2.10 examples/fetch.rb
astro-em-http-request-0.2.9 examples/fetch.rb
astro-em-http-request-0.2.8 examples/fetch.rb
astro-em-http-request-0.2.7 examples/fetch.rb
em-http-request-0.2.7 examples/fetch.rb
astro-em-http-request-0.2.6 examples/fetch.rb
em-http-request-0.2.6 examples/fetch.rb
em-http-request-0.2.5 examples/fetch.rb
em-http-request-0.2.4 examples/fetch.rb
em-http-request-0.2.3 examples/fetch.rb
astro-em-http-request-0.2.3 examples/fetch.rb
astro-em-http-request-0.2.2 examples/fetch.rb
em-http-request-0.2.2 examples/fetch.rb
em-http-request-0.2.1 examples/fetch.rb
em-http-request-0.2.0 examples/fetch.rb