Skip to content
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

fix #2247 #2249

Merged
merged 2 commits into from
Oct 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions requests/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
from .packages.urllib3.poolmanager import PoolManager, proxy_from_url
from .packages.urllib3.response import HTTPResponse
from .packages.urllib3.util import Timeout as TimeoutSauce
from .compat import urlparse, basestring, urldefrag
from .compat import urlparse, basestring
from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers,
prepend_scheme_if_needed, get_auth_from_url)
prepend_scheme_if_needed, get_auth_from_url, urldefragauth)
from .structures import CaseInsensitiveDict
from .packages.urllib3.exceptions import ConnectTimeoutError
from .packages.urllib3.exceptions import HTTPError as _HTTPError
Expand Down Expand Up @@ -270,7 +270,7 @@ def request_url(self, request, proxies):
proxy = proxies.get(scheme)

if proxy and scheme != 'https':
url, _ = urldefrag(request.url)
url = urldefragauth(request.url)
else:
url = request.path_url

Expand Down
15 changes: 15 additions & 0 deletions requests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,3 +672,18 @@ def to_native_string(string, encoding='ascii'):
out = string.decode(encoding)

return out


def urldefragauth(url):
"""
Given a url remove the fragment and the authentication part
"""
scheme, netloc, path, params, query, fragment = urlparse(url)

# see func:`prepend_scheme_if_needed`
if not netloc:
netloc, path = path, netloc

netloc = netloc.rsplit('@', 1)[-1]

return urlunparse((scheme, netloc, path, params, query, ''))