-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Excess leading path separators causes ConnectionPool.urlopen to parse URL as host & port #3352
Comments
I'm also worried about how this is handled in when handling redirects in the retry logic (e.g., server returns a |
Hi! I investigated a breakage introduced after I think the root cause of the issue is here in Therefore, the correct fix IMO is not to strip the URL but rather to parse the double slash into the "Path". |
@crabhi please let's keep discussion to one place for now |
Sure. I've posted the comment above before your first reply. I agree to keep the current discussion in the other issue. |
Subject
Originally reported in Requests (psf/requests#6643) but also applicable here,
:
is a valid character in a path per RFC3986. However, if a path is used in urllib3 where the path starts with//
then urllib3 interprets this as a scheme-less host and attempts to parse the hostname and port but the part after the:
may not be an integer.Environment
Describe your environment.
At least, paste here the output of:
Steps to Reproduce
Expected Behavior
If you have a server running on that port, a 200 OK, otherwise a connection error.
Actual Behavior
Part of this is that
u.request_uri
is properly parsed and returned as//v:h
butConnectionPool.urlopen
seems to be doing the same thing thatPoolManager.urlopen
does and the thing thatPoolManager.urlopen
is trying to delegate to it - i.e., it:urllib3/src/urllib3/connectionpool.py
Line 711 in d4ffa29
urllib3/src/urllib3/util/url.py
Line 425 in d4ffa29
If, however, we can (as early as possible) normalize the URL then we'll be in a better place. For example, this doesn't happen if you do this on the ConnectionPool level directly:
And so I think that in PoolManager specifically, we need to trim those leading
/
. There are a few ways to do this:The text was updated successfully, but these errors were encountered: