projects
/
services
/
python-requests.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a17110b
)
Handle redirection without scheme.
author
Jérémy Bethmont
<jeremy.bethmont@gmail.com>
Wed, 17 Aug 2011 14:04:53 +0000
(16:04 +0200)
committer
Jérémy Bethmont
<jeremy.bethmont@gmail.com>
Wed, 17 Aug 2011 14:04:53 +0000
(16:04 +0200)
requests/models.py
patch
|
blob
|
history
diff --git
a/requests/models.py
b/requests/models.py
index
cc9cc6f
..
931bafd
100644
(file)
--- a/
requests/models.py
+++ b/
requests/models.py
@@
-225,6
+225,11
@@
class Request(object):
url = r.headers['location']
+ # Handle redirection without scheme (see: RFC 1808 Section 4)
+ if url.startswith('//'):
+ parsed_rurl = urlparse(r.url)
+ url = '%s:%s' % (parsed_rurl.scheme, url)
+
# Facilitate non-RFC2616-compliant 'location' headers
# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
if not urlparse(url).netloc: