lib/httpx/plugins/proxy.rb in httpx-0.20.5 vs lib/httpx/plugins/proxy.rb in httpx-0.21.0

- old
+ new

@@ -103,10 +103,14 @@ end uris end return if @_proxy_uris.empty? + proxy = options.proxy + + return { uri: uri.host } if proxy && proxy.key?(:no_proxy) && !Array(proxy[:no_proxy]).grep(uri.host).empty? + proxy_opts = { uri: @_proxy_uris.first } proxy_opts = options.proxy.merge(proxy_opts) if options.proxy proxy_opts end @@ -115,10 +119,12 @@ uri = URI(request.uri) next_proxy = proxy_uris(uri, options) raise Error, "Failed to connect to proxy" unless next_proxy - proxy_options = options.merge(proxy: Parameters.new(**next_proxy)) + proxy = Parameters.new(**next_proxy) unless next_proxy[:uri] == uri.host + + proxy_options = options.merge(proxy: proxy) connection = pool.find_connection(uri, proxy_options) || build_connection(uri, proxy_options) unless connections.nil? || connections.include?(connection) connections << connection set_connection_callbacks(connection, connections, options) end