Public Class methods
new(*)
[show source]
# File lib/httpx/plugins/proxy.rb 179 def initialize(*) 180 super 181 @proxy_parameters = @options.proxy 182 end
Public Instance methods
find_connection(request_uri, selector, options)
[show source]
# File lib/httpx/plugins/proxy.rb 189 def find_connection(request_uri, selector, options) 190 if (next_proxy = request_uri.find_proxy) 191 return super(request_uri, selector, options.merge(proxy: Parameters.new(uri: next_proxy))) 192 end 193 194 return super unless @proxy_parameters 195 196 next_proxy = @proxy_parameters.uri 197 198 raise ProxyError, "Failed to connect to proxy" unless next_proxy 199 200 raise ProxyError, 201 "#{next_proxy.scheme}: unsupported proxy protocol" unless options.supported_proxy_protocols.include?(next_proxy.scheme) 202 203 if (no_proxy = @proxy_parameters.no_proxy) 204 no_proxy = no_proxy.join(",") if no_proxy.is_a?(Array) 205 206 unless no_proxy != "*" && # NO_PROXY=* bypasses proxy use 207 URI::Generic.use_proxy?(request_uri.host, next_proxy.host, next_proxy.port, no_proxy) 208 # TODO: setting proxy to nil leaks the connection object in the pool 209 return super(request_uri, selector, options.merge(proxy: nil)) 210 end 211 end 212 213 super(request_uri, selector, options.merge(proxy: @proxy_parameters)) 214 end
initialize_dup(other)
[show source]
# File lib/httpx/plugins/proxy.rb 184 def initialize_dup(other) 185 @proxy_parameters = other.instance_variable_get(:@proxy_parameters) 186 super 187 end