lib/httpx/plugins/proxy/http.rb in httpx-0.6.4 vs lib/httpx/plugins/proxy/http.rb in httpx-0.6.5
- old
+ new
@@ -39,11 +39,11 @@
end
super
end
def __http_proxy_connect
- req, _ = @pending.first
+ req = @pending.first
# if the first request after CONNECT is to an https address, it is assumed that
# all requests in the queue are not only ALL HTTPS, but they also share the certificate,
# and therefore, will share the connection.
#
if req.uri.scheme == "https"
@@ -53,21 +53,21 @@
else
transition(:connected)
end
end
- def __http_on_connect(_request, response)
+ def __http_on_connect(_, response)
if response.status == 200
- req, _ = @pending.first
+ req = @pending.first
request_uri = req.uri
@io = ProxySSL.new(@io, request_uri, @options)
transition(:connected)
throw(:called)
else
- pending = @pending.map(&:first) + @parser.pending
+ pending = @pending + @parser.pending
while (req = pending.shift)
- emit(:response, req, response)
+ req.emit(:response, response)
end
end
end
end
@@ -76,10 +76,12 @@
request.uri.to_s
end
def set_request_headers(request)
super
+ proxy_params = @options.proxy
+ request.headers["proxy-authorization"] = "Basic #{proxy_params.token_authentication}" if proxy_params.authenticated?
request.headers["proxy-connection"] = request.headers["connection"]
request.headers.delete("connection")
end
end
@@ -100,13 +102,11 @@
@requests.all? { |request| !request.response.nil? }
end
end
class ConnectRequest < Request
- def initialize(uri, options)
+ def initialize(uri, _options)
super(:connect, uri, {})
- proxy_params = options.proxy
- @headers["proxy-authentication"] = "Basic #{proxy_params.token_authentication}" if proxy_params.authenticated?
@headers.delete("accept")
end
def path
"#{@uri.hostname}:#{@uri.port}"