repositioned empty placeholder hash

This commit is contained in:
HoneyryderChuck 2024-09-30 18:20:11 +01:00
parent 69e7e533de
commit d77e97d31d
5 changed files with 25 additions and 26 deletions

View File

@ -2,28 +2,11 @@
require "httpx/version" 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 # Top-Level Namespace
# #
module HTTPX module HTTPX
EMPTY = [].freeze EMPTY = [].freeze
EMPTY_HASH = {}.freeze
# All plugins should be stored under this module/namespace. Can register and load # All plugins should be stored under this module/namespace. Can register and load
# plugins. # plugins.
@ -53,10 +36,26 @@ module HTTPX
m.synchronize { h[name] = mod } m.synchronize { h[name] = mod }
end end
end end
extend Chainable
end 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"
require "httpx/session_extensions" require "httpx/session_extensions"

View File

@ -101,4 +101,6 @@ module HTTPX
end end
end end
end end
extend Chainable
end end

View File

@ -64,7 +64,7 @@ module HTTPX
:persistent => false, :persistent => false,
:resolver_class => (ENV["HTTPX_RESOLVER"] || :native).to_sym, :resolver_class => (ENV["HTTPX_RESOLVER"] || :native).to_sym,
:resolver_options => { cache: true }, :resolver_options => { cache: true },
:pool_options => {}, :pool_options => EMPTY_HASH,
:ip_families => ip_address_families, :ip_families => ip_address_families,
}.freeze }.freeze
@ -121,8 +121,8 @@ module HTTPX
# :persistent :: whether to persist connections in between requests (defaults to <tt>true</tt>) # :persistent :: whether to persist connections in between requests (defaults to <tt>true</tt>)
# :resolver_class :: which resolver to use (defaults to <tt>:native</tt>, can also be <tt>:system<tt> for # :resolver_class :: which resolver to use (defaults to <tt>:native</tt>, can also be <tt>:system<tt> for
# using getaddrinfo or <tt>:https</tt> for DoH resolver, or a custom class) # using getaddrinfo or <tt>:https</tt> for DoH resolver, or a custom class)
# :resolver_options :: hash of options passed to the resolver # :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 # :pool_options :: hash of options passed to the connection pool (See Pool#initialize).
# :ip_families :: which socket families are supported (system-dependent) # :ip_families :: which socket families are supported (system-dependent)
# :origin :: HTTP origin to set on requests with relative path (ex: "https://api.serv.com") # :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") # :base_path :: path to prefix given relative paths with (ex: "/v2")

View File

@ -168,7 +168,7 @@ module HTTPX
if (no_proxy = proxy.no_proxy) if (no_proxy = proxy.no_proxy)
no_proxy = no_proxy.join(",") if no_proxy.is_a?(Array) 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, 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) next_proxy.port, no_proxy)
end end

View File

@ -1,8 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
module HTTPX module HTTPX
EMPTY_HASH = {}.freeze
# Class implementing the APIs being used publicly. # Class implementing the APIs being used publicly.
# #
# HTTPX.get(..) #=> delegating to an internal HTTPX::Session object. # HTTPX.get(..) #=> delegating to an internal HTTPX::Session object.