lib/httpx/plugins/proxy.rb in httpx-0.24.7 vs lib/httpx/plugins/proxy.rb in httpx-1.0.0

- old
+ new

@@ -26,39 +26,10 @@ end def extra_options(options) options.merge(supported_proxy_protocols: []) end - - if URI::Generic.methods.include?(:use_proxy?) - def use_proxy?(*args) - URI::Generic.use_proxy?(*args) - end - else - # https://github.com/ruby/uri/blob/ae07f956a4bea00b4f54a75bd40b8fa918103eed/lib/uri/generic.rb - def use_proxy?(hostname, addr, port, no_proxy) - hostname = hostname.downcase - dothostname = ".#{hostname}" - no_proxy.scan(/([^:,\s]+)(?::(\d+))?/) do |p_host, p_port| - if !p_port || port == p_port.to_i - if p_host.start_with?(".") - return false if hostname.end_with?(p_host.downcase) - else - return false if dothostname.end_with?(".#{p_host.downcase}") - end - if addr - begin - return false if IPAddr.new(p_host).include?(addr) - rescue IPAddr::InvalidAddressError - next - end - end - end - end - true - end - end end class Parameters attr_reader :uri, :username, :password, :scheme @@ -80,11 +51,11 @@ @scheme = scheme auth_scheme = scheme.to_s.capitalize - require_relative "authentication/#{scheme}" unless defined?(Authentication) && Authentication.const_defined?(auth_scheme, false) + require_relative "auth/#{scheme}" unless defined?(Authentication) && Authentication.const_defined?(auth_scheme, false) @authenticator = Authentication.const_get(auth_scheme).new(@username, @password, **extra) end def can_authenticate?(*args) @@ -160,11 +131,11 @@ if proxy.key?(:no_proxy) no_proxy = proxy[:no_proxy] no_proxy = no_proxy.join(",") if no_proxy.is_a?(Array) - return super(request, connections, options.merge(proxy: nil)) unless Proxy.use_proxy?(uri.host, next_proxy.host, - next_proxy.port, no_proxy) + return super(request, connections, options.merge(proxy: nil)) unless URI::Generic.use_proxy?(uri.host, next_proxy.host, + next_proxy.port, no_proxy) end proxy.merge(uri: next_proxy) end