Skip to content
Myr

Merge pull request #1660 from sigmavirus24/parse-cookies-when-users-set-host-header

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

Parse cookies when users set custom Host header

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 7ccbcd2, 6632fb8 · Browse files · 1 file+13 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

1 file+13 added−2 removed

  • other:+13 added−2 removed

1 file+13 added−2 removed

modified:requests/cookies.py+13 added-2 removed
6 unmodified lines
7"""89import time10import collections11from .compat import cookielib, urlparse, Morsel11from .compat import cookielib, urlparse, urlunparse, Morsel1213try:14 import threading15 # grr, pyflakes: this fixes "redefinition of unused 'threading'"
28 unmodified lines
44 def get_origin_req_host(self):45 return self.get_host()4647 def get_full_url(self):48 # Only return the response's URL if the user hadn't set the Host49 # header50 if not self._r.headers.get('Host'):48 return self._r.url51 return self._r.url52 # If they did set it, retrieve it and reconstruct the expected domain53 host = self._r.headers['Host']54 parsed = urlparse(self._r.url)55 # Reconstruct the URL as we expect it56 return urlunparse([57 parsed.scheme, host, parsed.path, parsed.params, parsed.query,58 parsed.fragment59 ])6061 def is_unverifiable(self):62 return True63
360 unmodified lines