Skip to content

Commit 2c51402

Browse files
committed
Don't pass userinfo through to proxies in path position
When requesting via an HTTP proxy, we put the entire URI in the position where usually the path and query string is expected. However, if the original URI included a basic auth section, we must not include it, but rather convert it to an Authorization header.
1 parent d483fa5 commit 2c51402

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/em-http/http_encoding.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ def encode_request(method, uri, query, connopts)
5353
# uri in request header, as opposed to a relative path.
5454
# Don't modify the header with CONNECT proxies. It's unneeded and will
5555
# cause 400 Bad Request errors with many standard setups.
56-
query = uri.join(query) if connopts.proxy && !connopts.connect_proxy?
56+
if connopts.proxy && !connopts.connect_proxy?
57+
query = uri.join(query)
58+
# Drop the userinfo, it's been converted to a header and won't be
59+
# accepted by the proxy
60+
query.userinfo = nil
61+
end
5762

5863
HTTP_REQUEST_HEADER % [method.to_s.upcase, query]
5964
end

0 commit comments

Comments
 (0)