Class: HTTPalooza::Players::NetHTTPPlayer
- Defined in:
- lib/httpalooza/players/net_http.rb
Instance Attribute Summary
Attributes inherited from Base
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
#response ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/httpalooza/players/net_http.rb', line 9 def response http = Net::HTTP.new(request.url.host, request.url.inferred_port) if request.ssl? http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end net_http_request = net_http_request_class.new(request.url.request_uri) if [:post, :put].include?(request.method) net_http_request.body = request.payload end (request.headers || {}).each do |key, value| net_http_request.send(:[]=, key, value) end net_http_response = http.request(net_http_request) Response.new(net_http_response.code, net_http_response.body) end |