From d77e97d31d059336f6d9fdc74db66943b6c18a65 Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Mon, 30 Sep 2024 18:20:11 +0100 Subject: [PATCH] repositioned empty placeholder hash --- lib/httpx.rb | 39 +++++++++++++++++++------------------- lib/httpx/chainable.rb | 2 ++ lib/httpx/options.rb | 6 +++--- lib/httpx/plugins/proxy.rb | 2 +- lib/httpx/session.rb | 2 -- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/lib/httpx.rb b/lib/httpx.rb index d5fcdfc3..fbf58215 100644 --- a/lib/httpx.rb +++ b/lib/httpx.rb @@ -2,28 +2,11 @@ require "httpx/version" -require "httpx/extensions" - -require "httpx/errors" -require "httpx/utils" -require "httpx/punycode" -require "httpx/domain_name" -require "httpx/altsvc" -require "httpx/callbacks" -require "httpx/loggable" -require "httpx/transcoder" -require "httpx/timers" -require "httpx/pool" -require "httpx/headers" -require "httpx/request" -require "httpx/response" -require "httpx/options" -require "httpx/chainable" - # Top-Level Namespace # module HTTPX EMPTY = [].freeze + EMPTY_HASH = {}.freeze # All plugins should be stored under this module/namespace. Can register and load # plugins. @@ -53,10 +36,26 @@ module HTTPX m.synchronize { h[name] = mod } end end - - extend Chainable end +require "httpx/extensions" + +require "httpx/errors" +require "httpx/utils" +require "httpx/punycode" +require "httpx/domain_name" +require "httpx/altsvc" +require "httpx/callbacks" +require "httpx/loggable" +require "httpx/transcoder" +require "httpx/timers" +require "httpx/pool" +require "httpx/headers" +require "httpx/request" +require "httpx/response" +require "httpx/options" +require "httpx/chainable" + require "httpx/session" require "httpx/session_extensions" diff --git a/lib/httpx/chainable.rb b/lib/httpx/chainable.rb index 73e7cf5e..a1adf6a2 100644 --- a/lib/httpx/chainable.rb +++ b/lib/httpx/chainable.rb @@ -101,4 +101,6 @@ module HTTPX end end end + + extend Chainable end diff --git a/lib/httpx/options.rb b/lib/httpx/options.rb index ebbf31e4..fc468d7e 100644 --- a/lib/httpx/options.rb +++ b/lib/httpx/options.rb @@ -64,7 +64,7 @@ module HTTPX :persistent => false, :resolver_class => (ENV["HTTPX_RESOLVER"] || :native).to_sym, :resolver_options => { cache: true }, - :pool_options => {}, + :pool_options => EMPTY_HASH, :ip_families => ip_address_families, }.freeze @@ -121,8 +121,8 @@ module HTTPX # :persistent :: whether to persist connections in between requests (defaults to true) # :resolver_class :: which resolver to use (defaults to :native, can also be :system for # using getaddrinfo or :https for DoH resolver, or a custom class) - # :resolver_options :: hash of options passed to the resolver - # :pool_options :: hash of options passed to the connection pool + # :resolver_options :: hash of options passed to the resolver. Accepted keys depend on the resolver type. + # :pool_options :: hash of options passed to the connection pool (See Pool#initialize). # :ip_families :: which socket families are supported (system-dependent) # :origin :: HTTP origin to set on requests with relative path (ex: "https://api.serv.com") # :base_path :: path to prefix given relative paths with (ex: "/v2") diff --git a/lib/httpx/plugins/proxy.rb b/lib/httpx/plugins/proxy.rb index 2191c8ee..d413729a 100644 --- a/lib/httpx/plugins/proxy.rb +++ b/lib/httpx/plugins/proxy.rb @@ -168,7 +168,7 @@ module HTTPX if (no_proxy = proxy.no_proxy) no_proxy = no_proxy.join(",") if no_proxy.is_a?(Array) - # TODO: setting proxy to nil leaks the connection object in the pool + # TODO: setting proxy to nil leaks the connection object in the pool return super(request_uri, selector, options.merge(proxy: nil)) unless URI::Generic.use_proxy?(request_uri.host, next_proxy.host, next_proxy.port, no_proxy) end diff --git a/lib/httpx/session.rb b/lib/httpx/session.rb index 21c964ff..291cc137 100644 --- a/lib/httpx/session.rb +++ b/lib/httpx/session.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true module HTTPX - EMPTY_HASH = {}.freeze - # Class implementing the APIs being used publicly. # # HTTPX.get(..) #=> delegating to an internal HTTPX::Session object.