examples/fetch.rb in em-http-request-0.3.0 vs examples/fetch.rb in em-http-request-1.0.0.beta.1
- old
+ new
@@ -1,30 +1,30 @@
-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.error
-
- pending -= 1
- EM.stop if pending < 1
- }
- end
-end
+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.error
+
+ pending -= 1
+ EM.stop if pending < 1
+ }
+ end
+end