Public Instance methods
find_connection(request_uri, selector, options)
[show source]
# File lib/httpx/plugins/proxy.rb 159 def find_connection(request_uri, selector, options) 160 return super unless options.respond_to?(:proxy) 161 162 if (next_proxy = request_uri.find_proxy) 163 return super(request_uri, selector, options.merge(proxy: Parameters.new(uri: next_proxy))) 164 end 165 166 proxy = options.proxy 167 168 return super unless proxy 169 170 next_proxy = proxy.uri 171 172 raise ProxyError, "Failed to connect to proxy" unless next_proxy 173 174 raise ProxyError, 175 "#{next_proxy.scheme}: unsupported proxy protocol" unless options.supported_proxy_protocols.include?(next_proxy.scheme) 176 177 if (no_proxy = proxy.no_proxy) 178 no_proxy = no_proxy.join(",") if no_proxy.is_a?(Array) 179 180 # TODO: setting proxy to nil leaks the connection object in the pool 181 return super(request_uri, selector, options.merge(proxy: nil)) unless URI::Generic.use_proxy?(request_uri.host, next_proxy.host, 182 next_proxy.port, no_proxy) 183 end 184 185 super(request_uri, selector, options.merge(proxy: proxy)) 186 end