Skip to content

fix #2247 - #2249

Merged
kennethreitz merged 2 commits into
psf:masterfrom
t-8ch:fix_2247
Oct 5, 2014
Merged

kennethreitz merged 2 commits into
psf:masterfrom
t-8ch:fix_2247

Conversation

@t-8ch

@t-8ch t-8ch commented Sep 25, 2014

Copy link
Copy Markdown
Contributor

We have to pass urllib3 the url without the authentication information,
else it will be parsed by httplib as a netloc and included in the request line
and Host header

We have to pass urllib3 the url without the authentication information,
else it will be parsed by httplib as a netloc and included in the request line
and Host header
@Lukasa

Lukasa commented Sep 25, 2014

Copy link
Copy Markdown
Member

This looks right, but it's hard for me to know because URLs are a crazy mess. I'll let @sigmavirus24 review this, he knows URLs better than I do.

@sigmavirus24

Copy link
Copy Markdown
Contributor

So if we used a better (read: less forgiving) URL parser library we wouldn't need to split on @ (like we do here). In principle this works fine. In reality, we should get something like rfc3986 into acceptable shape for @shazow or just make the Url object in urllib3 more RFC compliant (whichever works better) and use that for parsing the URL and reconstructing it. In short, you have 5 major components of the URL:

{scheme}://{authority}{/path}{?query}{#fragment}

And authority which we're dealing with right now has 3 sub-components so a URL would look like:

{scheme}://{userinfo@}{hostname}{:port}{/path}{?query}{#fragment}

rfc3986 would split this up and allow you to replace userinfo with None and then reconstruct the URL. For a quick fix, this is great. I'd rather not have so much URL/URI parsing logic in requests though, this is an HTTP library not an HTTP + URL + ... library.

Comment thread requests/adapters.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the import of urldefrag here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@t-8ch

t-8ch commented Sep 26, 2014

Copy link
Copy Markdown
Contributor Author

+∞. I think it would be best to have URL objects that are immutable and an API like URL.replace(userinfo=None, fragment=None)

@sigmavirus24

Copy link
Copy Markdown
Contributor

@t-8ch that's roughly rfc3986's API, except that I don't think I call it replace but maybe I do.... I'll double check later.

@shazow

shazow commented Sep 26, 2014

Copy link
Copy Markdown
Contributor

@sigmavirus24 Please open the specific issue with urllib3's url parser, no need to be backhanded. :)

@sigmavirus24

Copy link
Copy Markdown
Contributor

Sorry @shazow, it wasn't meant to be back handed. I'll pull together the list of things the object is missing and make an issue with it tonight.

@shazow

shazow commented Sep 26, 2014

Copy link
Copy Markdown
Contributor

Thanks. :)

@kennethreitz

Copy link
Copy Markdown
Contributor

What's the status of this?

@sigmavirus24

Copy link
Copy Markdown
Contributor

@kennethreitz 👍

kennethreitz added a commit that referenced this pull request Oct 5, 2014
@kennethreitz
kennethreitz merged commit 5850b1f into psf:master Oct 5, 2014
@t-8ch
t-8ch deleted the fix_2247 branch October 5, 2014 19:18
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants