Skip to content
Myr

Adjust patch to utilize requests utility functions

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

Use the utility class provided by requests to do native string transformation rather than recreating the wheel.

authored by Brian Bamsch · committed by Brian Bamsch · parent 550dc19 · Browse files · 1 file+3 added−7 removed
This commit

State

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

Diff stats

1 file+3 added−7 removed

  • other:+3 added−7 removed

1 file+3 added−7 removed

modified:requests/cookies.py+3 added-7 removed
11 unmodified lines
12import copy13import time14import calendar15import collections1617from . import utils18from .compat import cookielib, urlparse, urlunparse, Morsel1920try:21 import threading
34 unmodified lines
56 # header57 if not self._r.headers.get('Host'):58 return self._r.url59 # If they did set it, retrieve it and reconstruct the expected domain58 host = self._r.headers['Host']60 host = utils.to_native_string(self._r.headers['Host'], encoding='utf-8')61 parsed = urlparse(self._r.url)6061 # If parsed url is str type, ensure that host is also str type62 if isinstance(parsed.scheme, str) and not isinstance(host, str)\63 and isinstance(host, bytes):64 host = host.decode('ascii')6562 # Reconstruct the URL as we expect it63 return urlunparse([64 parsed.scheme, host, parsed.path, parsed.params, parsed.query,65 parsed.fragment
477 unmodified lines