# File lib/em-http/request.rb, line 59 def send_request(&blk) begin EventMachine.connect(@req.host, @req.port, EventMachine::HttpClient) { |c| c.uri = @req.uri c.method = @req.method c.options = @req.options c.comm_inactivity_timeout = @req.options[:timeout] c.pending_connect_timeout = @req.options[:timeout] blk.call(c) unless blk.nil? } rescue EventMachine::ConnectionError => e conn = EventMachine::HttpClient.new("") conn.on_error(e.message, true) conn.uri = @req.uri conn end end