Sha256: 2bff8117456a880ce1307d09da60e868cd9bff02058a412587b34bb1900eba7f

Contents?: true

Size: 565 Bytes

Versions: 2

Compression:

Stored size: 565 Bytes

Contents

require 'rubygems'
require 'ZMachine'
require '../lib/z-http'

urls = ARGV
if urls.size < 1
  puts "Usage: #{$0} <url> <url> <...>"
  exit
end

pending = urls.size

ZMachine.run do
  urls.each do |url|
    http = ZMachine::HttpRequest.new(url).get
    http.callback {
      puts "#{url}\n#{http.response_header.status} - #{http.response.length} bytes\n"
      puts http.response

      pending -= 1
      ZMachine.stop if pending < 1
    }
    http.errback {
      puts "#{url}\n" + http.error

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
z-http-request-0.2.0 examples/fetch.rb
z-http-request-0.1.0 examples/fetch.rb