summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2006-12-22 19:08:41 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2006-12-22 19:08:41 (GMT)
commit60775f29de0e6107a46f668144cb1c133d6e5147 (patch)
tree1ab918acdd1d5f851707d2769f01e7599fa7d4e1 /Lib
parentbbad84b41aa73a3cf4be1fe41ca5fde3814af9ca (diff)
downloadcpython-60775f29de0e6107a46f668144cb1c133d6e5147.zip
cpython-60775f29de0e6107a46f668144cb1c133d6e5147.tar.gz
cpython-60775f29de0e6107a46f668144cb1c133d6e5147.tar.bz2
[Patch #827559 from Chris Gonnerman] Make SimpleHTTPServer redirect when a directory URL is missing the trailing slash; this lets relative links work.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/SimpleHTTPServer.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py
index fae551a..86c669e 100644
--- a/Lib/SimpleHTTPServer.py
+++ b/Lib/SimpleHTTPServer.py
@@ -66,6 +66,12 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
path = self.translate_path(self.path)
f = None
if os.path.isdir(path):
+ if not self.path.endswith('/'):
+ # redirect browser - doing basically what apache does
+ self.send_response(301)
+ self.send_header("Location", self.path + "/")
+ self.end_headers()
+ return None
for index in "index.html", "index.htm":
index = os.path.join(path, index)
if os.path.exists(index):