diff --git a/requests/cookies.py b/requests/cookies.py index 4d1708d4..a53f2104 100644 --- a/requests/cookies.py +++ b/requests/cookies.py @@ -45,10 +45,14 @@ class MockRequest(object): return self.get_host() def get_full_url(self): + # Only return the response's URL if the user hadn't set the Host + # header if not self._r.headers.get('Host'): return self._r.url + # If they did set it, retrieve it and reconstruct the expected doain host = self._r.headers['Host'] parsed = urlparse(self._r.url) + # Reconstruct the URL as we expect it return urlunparse([ parsed.scheme, host, parsed.path, parsed.params, parsed.query, parsed.fragment