From: Benjamin Peterson Date: Fri, 26 Dec 2014 16:56:51 +0000 (-0600) Subject: merge 3.4 (#23112) X-Git-Tag: v3.5.0a1~273 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fe975a234fec6fa9c88b1d90d97542398267a484;p=thirdparty%2FPython%2Fcpython.git merge 3.4 (#23112) --- fe975a234fec6fa9c88b1d90d97542398267a484 diff --cc Lib/http/server.py index 02e9cc2af836,cfa29f44d351..ac53550a9722 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@@ -648,10 -701,14 +648,14 @@@ class SimpleHTTPRequestHandler(BaseHTTP 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(301) + 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": diff --cc Misc/NEWS index 97b329aa4914,82cdbfd5a722..45dd5b4307f4 --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -196,9 -41,9 +196,12 @@@ Core and Builtin Library ------- + - Issue #23112: Fix SimpleHTTPServer to correctly carry the query string and + fragment when it redirects to add a trailing slash. + +- Issue #21793: Added http.HTTPStatus enums (i.e. HTTPStatus.OK, + HTTPStatus.NOT_FOUND). Patch by Demian Brecht. + - Issue #23093: In the io, module allow more operations to work on detached streams.