Skip to content

misc: Added faraday adapter_options #713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/twilio-ruby/http/http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module Twilio
module HTTP
class Client
attr_accessor :adapter
attr_accessor :adapter, :adapter_options
attr_reader :timeout, :last_response, :last_request, :connection

def initialize(proxy_prot = nil, proxy_addr = nil, proxy_port = nil, proxy_user = nil, proxy_pass = nil,
Expand All @@ -15,6 +15,13 @@ def initialize(proxy_prot = nil, proxy_addr = nil, proxy_port = nil, proxy_user
@proxy_auth = "#{proxy_user}:#{proxy_pass}@" if proxy_pass && proxy_user
@timeout = timeout
@adapter = Faraday.default_adapter
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.1')
# for faraday 2.1 and higher
@adapter_options = Faraday.default_adapter_options
else
# for faraday 1.x and 2.0
@adapter_options = {}
end
@configure_connection_blocks = []
end

Expand Down Expand Up @@ -49,7 +56,7 @@ def _request(request) # rubocop:disable Metrics/MethodLength
f.params = request.params.nil? ? {} : request.params

@configure_connection_blocks.each { |block| block.call(f) }
f.adapter @adapter
f.adapter @adapter, **@adapter_options
end

@last_request = request
Expand Down