lib/em-synchrony/em-http.rb in em-synchrony-0.3.0.beta.1 vs lib/em-synchrony/em-http.rb in em-synchrony-1.0.0
- old
+ new
@@ -1,7 +1,7 @@
begin
- require "em-http"
+ require "em-http-request"
rescue LoadError => error
raise "Missing EM-Synchrony dependency: gem install em-http-request"
end
module EventMachine
@@ -10,14 +10,18 @@
class_eval %[
alias :a#{type} :#{type}
def #{type}(options = {}, &blk)
f = Fiber.current
- conn = setup_request(:#{type}, options, &blk)
- conn.callback { f.resume(conn) }
- conn.errback { f.resume(conn) }
-
- Fiber.yield
+ conn = setup_request(:#{type}, options, &blk)
+ if conn.error.nil?
+ conn.callback { f.resume(conn) }
+ conn.errback { f.resume(conn) }
+
+ Fiber.yield
+ else
+ conn
+ end
end
]
end
end
end