mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-08 00:03:41 -04:00
Merge pull request #85 from wlmcewen/typhoeus_fix
Typhoeus adapter does not accept custom user agent
This commit is contained in:
commit
a919c4d177
@ -19,6 +19,7 @@ module Faraday
|
|||||||
:method => env[:method],
|
:method => env[:method],
|
||||||
:body => env[:body],
|
:body => env[:body],
|
||||||
:headers => env[:request_headers],
|
:headers => env[:request_headers],
|
||||||
|
:user_agent => env[:request_headers][:user_agent],
|
||||||
:disable_ssl_peer_verification => (env[:ssl] && !env[:ssl].fetch(:verify, true))
|
:disable_ssl_peer_verification => (env[:ssl] && !env[:ssl].fetch(:verify, true))
|
||||||
|
|
||||||
if ssl = env[:ssl]
|
if ssl = env[:ssl]
|
||||||
|
24
test/adapters/typhoeus_test.rb
Normal file
24
test/adapters/typhoeus_test.rb
Normal 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
|
Loading…
x
Reference in New Issue
Block a user