Skip to content
Myr

Merge pull request #2 from requests/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Syncing fork to the original repository

authored by Maina Nick · committed by GitHub · parents ccbffe5, eaab47f · Browse files · 3 files+24 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+24 added−2 removed

  • tests:+11 added−0 removed
  • other:+13 added−2 removed

3 files+24 added−2 removed

modified:requests/sessions.py+11 added-2 removed
17 unmodified lines
18 cookiejar_from_dict, extract_cookies_to_jar, RequestsCookieJar, merge_cookies)19from .models import Request, PreparedRequest, DEFAULT_REDIRECT_LIMIT20from .hooks import default_hooks, dispatch_hook21from ._internal_utils import to_native_string22from .utils import to_key_val_list, default_headers22from .utils import to_key_val_list, default_headers, DEFAULT_PORTS23from .exceptions import (24 TooManyRedirects, InvalidSchema, ChunkedEncodingError, ContentDecodingError)2526from .structures import CaseInsensitiveDict
100 unmodified lines
127 # that allowed any redirects on the same host.128 if (old_parsed.scheme == 'http' and old_parsed.port in (80, None)129 and new_parsed.scheme == 'https' and new_parsed.port in (443, None)):130 return False131132 # Handle default port usage corresponding to scheme.133 changed_port = old_parsed.port != new_parsed.port134 changed_scheme = old_parsed.scheme != new_parsed.scheme135 default_port = (DEFAULT_PORTS.get(old_parsed.scheme, None), None)136 if (not changed_scheme and old_parsed.port in default_port137 and new_parsed.port in default_port):138 return False139140 # Standard case: root URI must match132 return old_parsed.port != new_parsed.port or old_parsed.scheme != new_parsed.scheme141 return changed_port or changed_scheme142143 def resolve_redirects(self, resp, req, stream=False, timeout=None,144 verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs):145 """Receives a Response. Returns a generator of Responses or Requests."""
625 unmodified lines
modified:requests/utils.py+2 added
36 unmodified lines
37NETRC_FILES = ('.netrc', '_netrc')3839DEFAULT_CA_BUNDLE_PATH = certs.where()4041DEFAULT_PORTS = {'http': 80, 'https': 443}424344if sys.platform == 'win32':45 # provide a proxy_bypass version on Windows without DNS lookups4647 def proxy_bypass_registry(host):
930 unmodified lines
modified:tests/test_requests.py+11 added
1609 unmodified lines
1610 def test_should_strip_auth_port_change(self):1611 s = requests.Session()1612 assert s.should_strip_auth('http://example.com:1234/foo', 'https://example.com:4321/bar')16131614 @pytest.mark.parametrize(1615 'old_uri, new_uri', (1616 ('https://example.com:443/foo', 'https://example.com/bar'),1617 ('http://example.com:80/foo', 'http://example.com/bar'),1618 ('https://example.com/foo', 'https://example.com:443/bar'),1619 ('http://example.com/foo', 'http://example.com:80/bar')1620 ))1621 def test_should_strip_auth_default_port(self, old_uri, new_uri):1622 s = requests.Session()1623 assert not s.should_strip_auth(old_uri, new_uri)16241625 def test_manual_redirect_with_partial_body_read(self, httpbin):1626 s = requests.Session()1627 r1 = s.get(httpbin('redirect/2'), allow_redirects=False, stream=True)1628 assert r1.is_redirect
890 unmodified lines