From e9e038f28242f2bb5b19f48879539c061968382f Mon Sep 17 00:00:00 2001 From: Oliver Morgan Date: Tue, 27 Feb 2024 12:08:31 +0000 Subject: [PATCH] Added faraday adapter_options --- lib/twilio-ruby/http/http_client.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/twilio-ruby/http/http_client.rb b/lib/twilio-ruby/http/http_client.rb index 0a0607012..a53b93104 100644 --- a/lib/twilio-ruby/http/http_client.rb +++ b/lib/twilio-ruby/http/http_client.rb @@ -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, @@ -16,6 +16,13 @@ def initialize(proxy_prot = nil, proxy_addr = nil, proxy_port = nil, proxy_user @ssl_ca_file = ssl_ca_file @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 @@ -42,7 +49,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