summaryrefslogtreecommitdiffstats
path: root/Lib/http
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-12-26 16:56:51 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-12-26 16:56:51 (GMT)
commitfe975a234fec6fa9c88b1d90d97542398267a484 (patch)
tree01be79ca7375ecf8a69670fce02581f5ac4f63ce /Lib/http
parentf2ad173eaf38140bd72a849f47e0427b3d941692 (diff)
parent94cb7a24298ee0a4d6a3bb6b8ae80a7729e9f788 (diff)
downloadcpython-fe975a234fec6fa9c88b1d90d97542398267a484.zip
cpython-fe975a234fec6fa9c88b1d90d97542398267a484.tar.gz
cpython-fe975a234fec6fa9c88b1d90d97542398267a484.tar.bz2
merge 3.4 (#23112)
Diffstat (limited to 'Lib/http')
-rw-r--r--Lib/http/server.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py
index 02e9cc2..ac53550 100644
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -648,10 +648,14 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
path = self.translate_path(self.path)
f = None
if os.path.isdir(path):
- if not self.path.endswith('/'):
+ parts = urllib.parse.urlsplit(self.path)
+ if not parts.path.endswith('/'):
# redirect browser - doing basically what apache does
self.send_response(HTTPStatus.MOVED_PERMANENTLY)
- self.send_header("Location", self.path + "/")
+ new_parts = (parts[0], parts[1], parts[2] + '/',
+ parts[3], parts[4])
+ new_url = urllib.parse.urlunsplit(new_parts)
+ self.send_header("Location", new_url)
self.end_headers()
return None
for index in "index.html", "index.htm":