189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
# File 'lib/httpx/plugins/proxy.rb', line 189
def find_connection(request_uri, selector, options)
if (next_proxy = request_uri.find_proxy)
return super(request_uri, selector, options.merge(proxy: Parameters.new(uri: next_proxy)))
end
return super unless @proxy_parameters
next_proxy = @proxy_parameters.uri
raise ProxyError, "Failed to connect to proxy" unless next_proxy
raise ProxyError,
"#{next_proxy.scheme}: unsupported proxy protocol" unless options.supported_proxy_protocols.include?(next_proxy.scheme)
if (no_proxy = @proxy_parameters.no_proxy)
no_proxy = no_proxy.join(",") if no_proxy.is_a?(Array)
unless no_proxy != "*" && URI::Generic.use_proxy?(request_uri.host, next_proxy.host, next_proxy.port, no_proxy)
return super(request_uri, selector, options.merge(proxy: nil))
end
end
super(request_uri, selector, options.merge(proxy: @proxy_parameters))
end
|