summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-08-16 14:44:32 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2008-08-16 14:44:32 (GMT)
commit72dc1eadd918dc9ddd6a30149d90617d706a0b19 (patch)
tree39152c04863345c7f9f20c4326570ae3c01a0e50 /Lib/urllib
parent371bb50b87e0450bf4bcf06ac89a47a417bf908f (diff)
downloadcpython-72dc1eadd918dc9ddd6a30149d90617d706a0b19.zip
cpython-72dc1eadd918dc9ddd6a30149d90617d706a0b19.tar.gz
cpython-72dc1eadd918dc9ddd6a30149d90617d706a0b19.tar.bz2
Issue #2776: fixed small issue when handling an URL with double slash
after a 302 response in the case of not going through a proxy.
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/request.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index c050ed8..428be4a 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -231,6 +231,9 @@ class Request:
self.host, self.type = host, type
self.__r_host = self.__original
+ def has_proxy(self):
+ return self.__r_host == self.__original
+
def get_origin_req_host(self):
return self.origin_req_host
@@ -1010,10 +1013,12 @@ class AbstractHTTPHandler(BaseHandler):
request.add_unredirected_header(
'Content-length', '%d' % len(data))
- scheme, sel = splittype(request.get_selector())
- sel_host, sel_path = splithost(sel)
+ sel_host = host
+ if request.has_proxy():
+ scheme, sel = splittype(request.get_selector())
+ sel_host, sel_path = splithost(sel)
if not request.has_header('Host'):
- request.add_unredirected_header('Host', sel_host or host)
+ request.add_unredirected_header('Host', sel_host)
for name, value in self.parent.addheaders:
name = name.capitalize()
if not request.has_header(name):