mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Support relative redirects. Fixes #36
This commit is contained in:
@@ -177,6 +177,12 @@ class Request(object):
|
||||
|
||||
url = r.headers['location']
|
||||
|
||||
# Facilitate for non-RFC2616-compliant 'location' headers
|
||||
# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
|
||||
if not urlparse(url).netloc:
|
||||
parent_url_components = urlparse(self.url)
|
||||
url = '%s://%s/%s' % (parent_url_components.scheme, parent_url_components.netloc, url)
|
||||
|
||||
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4
|
||||
if r.status_code is 303:
|
||||
method = 'GET'
|
||||
|
||||
Reference in New Issue
Block a user