Class: HTTPalooza::Players::EmHttpRequestPlayer

Inherits:
Base
  • Object
show all
Defined in:
lib/httpalooza/players/em_http_request.rb

Instance Attribute Summary

Attributes inherited from Base

#request

Instance Method Summary collapse

Methods inherited from Base

execute!, #initialize, introducing!, #name

Constructor Details

This class inherits a constructor from HTTPalooza::Players::Base

Instance Method Details

#responseObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/httpalooza/players/em_http_request.rb', line 6

def response
  response = nil
  EM.synchrony do
    http_request = EventMachine::HttpRequest.new(request.url)
    http_client = http_request.send(request.method, :body => request.payload, :head => request.headers)
    response = Response.new(http_client.response_header.status, http_client.response)
    EM.stop
  end
  response
end