diff --git a/lib/httpx/plugins/aws_sdk_authentication.rb b/lib/httpx/plugins/aws_sdk_authentication.rb index b3cd2ad2..48ed9064 100644 --- a/lib/httpx/plugins/aws_sdk_authentication.rb +++ b/lib/httpx/plugins/aws_sdk_authentication.rb @@ -32,9 +32,8 @@ module HTTPX class << self attr_reader :credentials, :region - def load_dependencies(klass) + def load_dependencies(_klass) require "aws-sdk-core" - klass.plugin(:aws_sigv4) client = Class.new(Seahorse::Client::Base) do @identifier = :httpx @@ -50,6 +49,10 @@ module HTTPX @region = client.config[:region] end + def configure(klass) + klass.plugin(:aws_sigv4) + end + def extra_options(options) options.merge(max_concurrent_requests: 1) end diff --git a/lib/httpx/plugins/basic_authentication.rb b/lib/httpx/plugins/basic_authentication.rb index ec1409d8..dc68d679 100644 --- a/lib/httpx/plugins/basic_authentication.rb +++ b/lib/httpx/plugins/basic_authentication.rb @@ -8,9 +8,14 @@ module HTTPX # https://gitlab.com/honeyryderchuck/httpx/wikis/Authentication#basic-authentication # module BasicAuthentication - def self.load_dependencies(klass) - require "base64" - klass.plugin(:authentication) + class << self + def load_dependencies(_klass) + require "base64" + end + + def configure(klass) + klass.plugin(:authentication) + end end module InstanceMethods diff --git a/lib/httpx/plugins/compression/brotli.rb b/lib/httpx/plugins/compression/brotli.rb index a27b23b2..f69f07f1 100644 --- a/lib/httpx/plugins/compression/brotli.rb +++ b/lib/httpx/plugins/compression/brotli.rb @@ -5,12 +5,12 @@ module HTTPX module Compression module Brotli class << self - def load_dependencies(klass) - klass.plugin(:compression) + def load_dependencies(_klass) require "brotli" end def configure(klass) + klass.plugin(:compression) klass.default_options.encodings.register "br", self end end diff --git a/lib/httpx/plugins/compression/deflate.rb b/lib/httpx/plugins/compression/deflate.rb index 7ccad027..6f871717 100644 --- a/lib/httpx/plugins/compression/deflate.rb +++ b/lib/httpx/plugins/compression/deflate.rb @@ -4,13 +4,13 @@ module HTTPX module Plugins module Compression module Deflate - def self.load_dependencies(klass) + def self.load_dependencies(_klass) require "stringio" require "zlib" - klass.plugin(:"compression/gzip") end def self.configure(klass) + klass.plugin(:"compression/gzip") klass.default_options.encodings.register "deflate", self end diff --git a/lib/httpx/plugins/rate_limiter.rb b/lib/httpx/plugins/rate_limiter.rb index bb0a2bc8..804eb99f 100644 --- a/lib/httpx/plugins/rate_limiter.rb +++ b/lib/httpx/plugins/rate_limiter.rb @@ -15,7 +15,7 @@ module HTTPX class << self RATE_LIMIT_CODES = [429, 503].freeze - def load_dependencies(klass) + def configure(klass) klass.plugin(:retries, retry_change_requests: true, retry_on: method(:retry_on_rate_limited_response), diff --git a/sig/plugins/aws_sdk_authentication.rbs b/sig/plugins/aws_sdk_authentication.rbs index d7b207f6..acfc7ef1 100644 --- a/sig/plugins/aws_sdk_authentication.rbs +++ b/sig/plugins/aws_sdk_authentication.rbs @@ -7,6 +7,8 @@ module HTTPX def self.load_dependencies: (singleton(Session)) -> void + def self.configure: (singleton(Session)) -> void + def self.extra_options: (Options) -> (Options) module InstanceMethods diff --git a/sig/plugins/basic_authentication.rbs b/sig/plugins/basic_authentication.rbs index 80dce5e2..b92d00d0 100644 --- a/sig/plugins/basic_authentication.rbs +++ b/sig/plugins/basic_authentication.rbs @@ -3,6 +3,8 @@ module HTTPX module BasicAuthentication def self.load_dependencies: (singleton(Session)) -> void + def self.configure: (singleton(Session)) -> void + module InstanceMethods def basic_authentication: (string user, string password) -> instance end