Merge pull request #85 from wlmcewen/typhoeus_fix

Typhoeus adapter does not accept custom user agent
This commit is contained in:
Erik Michaels-Ober 2011-10-11 16:05:59 -07:00
commit a919c4d177
2 changed files with 25 additions and 0 deletions

View File

@ -19,6 +19,7 @@ module Faraday
:method => env[:method],
:body => env[:body],
:headers => env[:request_headers],
:user_agent => env[:request_headers][:user_agent],
:disable_ssl_peer_verification => (env[:ssl] && !env[:ssl].fetch(:verify, true))
if ssl = env[:ssl]

View File

@ -0,0 +1,24 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helper'))
module Adapters
class TyphoeusTest < Faraday::TestCase
def setup
@connection = Faraday.new('http://disney.com') do |b|
b.adapter :typhoeus
end
end
def test_handles_user_agent
# default typhoeus agent
stub_request(:get, 'disney.com/hello').with(:headers => {'User-Agent'=>'Typhoeus - http://github.com/dbalatero/typhoeus/tree/master'}){ |request|
request.headers["User-Agent"] == 'Typhoeus - http://github.com/dbalatero/typhoeus/tree/master'
}
@connection.get('/hello')
stub_request(:get, 'disney.com/world').with(:headers => {'User-Agent'=>'Faraday Agent'}){ |request|
request.headers["User-Agent"] == 'Faraday Agent'
}
@connection.get('/world', :user_agent => 'Faraday Agent')
end
end
end