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

+ (Object) connect(rack_request)



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

+ (Object) parameters_for(request)



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

- (Object) connect(rack_request)



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

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