lib/em-net-http.rb in em-net-http-0.2.3 vs lib/em-net-http.rb in em-net-http-0.2.4
- old
+ new
@@ -99,10 +99,11 @@
headers[k] = v
end
headers['content-type'] ||= "application/x-www-form-urlencoded"
+ t0 = Time.now
httpreq = EM::HttpRequest.new(uri).send(req.class::METHOD.downcase.to_sym, opts)
f=Fiber.current
convert_em_http_response = lambda do |res|
@@ -118,10 +119,14 @@
end
httpreq.callback &convert_em_http_response
httpreq.errback {|err|f.resume(:error)}
res = Fiber.yield
- raise 'EM::HttpRequest error - request timed out?' if res == :error
+ if res == :error
+ raise 'EM::HttpRequest error - request timed out' if Time.now - self.read_timeout > t0
+ raise 'EM::HttpRequest error - unknown error'
+ end
+
yield res if block_given?
res
end
end