Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
python-requests
02-proper-handl-ports-auth-strip.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 02-proper-handl-ports-auth-strip.patch of Package python-requests
From ea9436a5d6a5934a906e91202349aabf9af75d15 Mon Sep 17 00:00:00 2001 From: Nate Prewitt <Nate.Prewitt@gmail.com> Date: Sun, 28 Oct 2018 23:17:39 -0700 Subject: [PATCH] proper handling for default ports in auth stripping --- requests/sessions.py | 13 +++++++++++-- requests/utils.py | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) --- a/requests/sessions.py +++ b/requests/sessions.py @@ -17,7 +17,7 @@ from .cookies import ( cookiejar_from_dict, extract_cookies_to_jar, RequestsCookieJar, merge_cookies) from .models import Request, PreparedRequest, DEFAULT_REDIRECT_LIMIT from .hooks import default_hooks, dispatch_hook -from .utils import to_key_val_list, default_headers, to_native_string +from .utils import to_key_val_list, default_headers, to_native_string, DEFAULT_PORTS from .exceptions import ( TooManyRedirects, InvalidSchema, ChunkedEncodingError, ContentDecodingError) from .packages.urllib3._collections import RecentlyUsedContainer @@ -98,8 +98,17 @@ class SessionRedirectMixin(object): if (old_parsed.scheme == 'http' and old_parsed.port in (80, None) and new_parsed.scheme == 'https' and new_parsed.port in (443, None)): return False + + # Handle default port usage corresponding to scheme. + changed_port = old_parsed.port != new_parsed.port + changed_scheme = old_parsed.scheme != new_parsed.scheme + default_port = (DEFAULT_PORTS.get(old_parsed.scheme, None), None) + if (not changed_scheme and old_parsed.port in default_port + and new_parsed.port in default_port): + return False + # Standard case: root URI must match - return old_parsed.port != new_parsed.port or old_parsed.scheme != new_parsed.scheme + return changed_port or changed_scheme def resolve_redirects(self, resp, req, stream=False, timeout=None, verify=True, cert=None, proxies=None, **adapter_kwargs): --- a/requests/utils.py +++ b/requests/utils.py @@ -34,6 +34,8 @@ NETRC_FILES = ('.netrc', '_netrc') DEFAULT_CA_BUNDLE_PATH = certs.where() +DEFAULT_PORTS = {'http': 80, 'https': 443} + def dict_to_sequence(d): """Returns an internal sequence dictionary update."""
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor