Class: Weary::Adapter::Typhoeus

Inherits:
Object
  • Object
show all
Extended by:
Weary::Adapter
Includes:
Weary::Adapter
Defined in:
lib/weary/adapters/typhoeus.rb

Constant Summary

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Weary::Adapter

call, initialize, normalize_request_headers, normalize_response

Class Method Details

.connect(rack_request) ⇒ Object



10
11
12
13
# File 'lib/weary/adapters/typhoeus.rb', line 10

def connect(rack_request)
  response = ::Typhoeus::Request.new(rack_request.url, parameters_for(rack_request)).run
  Rack::Response.new response.body, response.code, response.headers_hash
end

.parameters_for(request) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/weary/adapters/typhoeus.rb', line 15

def parameters_for(request)
  typhoeus_params = { :headers => normalize_request_headers(request.env),
                      :method  => request.request_method.downcase.to_sym,
                      :body => request.body.read }
  request.body.rewind
  typhoeus_params
end

Instance Method Details

#connect(rack_request) ⇒ Object



26
27
28
# File 'lib/weary/adapters/typhoeus.rb', line 26

def connect(rack_request)
  self.class.connect(rack_request)
end