mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-04 00:02:03 -04:00
External Typhoeus Adapter Compatibility (#748)
This commit is contained in:
parent
53b5e087e9
commit
b302d708ea
1
Gemfile
1
Gemfile
@ -21,6 +21,7 @@ group :test do
|
||||
gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
|
||||
gem 'simplecov'
|
||||
gem 'sinatra', '~> 1.3'
|
||||
gem 'typhoeus', '~> 1.3', :require => 'typhoeus'
|
||||
end
|
||||
|
||||
gemspec
|
||||
|
@ -8,6 +8,7 @@ module Faraday
|
||||
:test => [:Test, 'test'],
|
||||
:net_http => [:NetHttp, 'net_http'],
|
||||
:net_http_persistent => [:NetHttpPersistent, 'net_http_persistent'],
|
||||
:typhoeus => [:Typhoeus, 'typhoeus'],
|
||||
:patron => [:Patron, 'patron'],
|
||||
:em_synchrony => [:EMSynchrony, 'em_synchrony'],
|
||||
:em_http => [:EMHttp, 'em_http'],
|
||||
|
12
lib/faraday/adapter/typhoeus.rb
Normal file
12
lib/faraday/adapter/typhoeus.rb
Normal file
@ -0,0 +1,12 @@
|
||||
module Faraday
|
||||
class Adapter
|
||||
# This class is just a stub, the real adapter is in https://github.com/philsturgeon/typhoeus/blob/master/lib/typhoeus/adapters/faraday.rb
|
||||
class Typhoeus < Faraday::Adapter
|
||||
# Needs to define this method in order to support Typhoeus <= 1.3.0
|
||||
def call; end
|
||||
|
||||
dependency 'typhoeus'
|
||||
dependency 'typhoeus/adapters/faraday'
|
||||
end
|
||||
end
|
||||
end
|
@ -55,6 +55,7 @@ module Faraday
|
||||
:NetHttpPersistent => 'net_http_persistent',
|
||||
:EMSynchrony => 'em_synchrony',
|
||||
:EMHttp => 'em_http',
|
||||
:Typhoeus => 'typhoeus',
|
||||
:Patron => 'patron',
|
||||
:Excon => 'excon',
|
||||
:Test => 'test',
|
||||
|
38
test/adapters/typhoeus_test.rb
Normal file
38
test/adapters/typhoeus_test.rb
Normal file
@ -0,0 +1,38 @@
|
||||
require File.expand_path('../integration', __FILE__)
|
||||
|
||||
module Adapters
|
||||
class TyphoeusTest < Faraday::TestCase
|
||||
|
||||
def adapter() :typhoeus end
|
||||
|
||||
Integration.apply(self, :Parallel) do
|
||||
# inconsistent outcomes ranging from successful response to connection error
|
||||
undef :test_proxy_auth_fail if ssl_mode?
|
||||
|
||||
# Typhoeus adapter not supporting Faraday::SSLError
|
||||
undef :test_GET_ssl_fails_with_bad_cert if ssl_mode?
|
||||
|
||||
def test_binds_local_socket
|
||||
host = '1.2.3.4'
|
||||
conn = create_connection :request => { :bind => { :host => host } }
|
||||
assert_equal host, conn.options[:bind][:host]
|
||||
end
|
||||
|
||||
# Typhoeus::Response doesn't provide an easy way to access the reason phrase,
|
||||
# so override the shared test from Common.
|
||||
def test_GET_reason_phrase
|
||||
response = get('echo')
|
||||
assert_nil response.reason_phrase
|
||||
end
|
||||
end
|
||||
|
||||
def test_custom_adapter_config
|
||||
adapter = Faraday::Adapter::Typhoeus.new(nil, { :forbid_reuse => true, :maxredirs => 1 })
|
||||
|
||||
request = adapter.method(:typhoeus_request).call({})
|
||||
|
||||
assert_equal true, request.options[:forbid_reuse]
|
||||
assert_equal 1, request.options[:maxredirs]
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user