mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-12-05 00:02:12 -05:00
options: always load plugins in the .configure callback
This commit is contained in:
parent
ae4b7545b2
commit
e436c4fa04
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user