]> granicus.if.org Git - python/commitdiff
merge 3.4 (#23112)
authorBenjamin Peterson <benjamin@python.org>
Fri, 26 Dec 2014 16:56:51 +0000 (10:56 -0600)
committerBenjamin Peterson <benjamin@python.org>
Fri, 26 Dec 2014 16:56:51 +0000 (10:56 -0600)
1  2 
Lib/http/server.py
Misc/NEWS

index 02e9cc2af836f4cf3dfd34603f433ac964f9e451,cfa29f44d351cfd3ac6e8ea05d18b6d43c148e2b..ac53550a9722e6599c4c7adc51645ad780c358eb
@@@ -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 97b329aa49147dfeb4cc3c5f63ed7b536223bfda,82cdbfd5a7225d94291414bf02efceb37a55c969..45dd5b4307f40207e9aa772d7a898459fee394ec
+++ 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.