diff options
| author | Andrew M. Kuchling <amk@amk.ca> | 2006-12-22 19:06:16 (GMT) | 
|---|---|---|
| committer | Andrew M. Kuchling <amk@amk.ca> | 2006-12-22 19:06:16 (GMT) | 
| commit | 428190254510d3bc6eabf290fb138980784c38bb (patch) | |
| tree | 51ebc513b6c2eeed0fa11a1ab5ef770d04f049b7 /Lib/SimpleHTTPServer.py | |
| parent | ee0e6d16b371a66e1d9ab8103fb51117db37cdbc (diff) | |
| download | cpython-428190254510d3bc6eabf290fb138980784c38bb.zip cpython-428190254510d3bc6eabf290fb138980784c38bb.tar.gz cpython-428190254510d3bc6eabf290fb138980784c38bb.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/SimpleHTTPServer.py')
| -rw-r--r-- | Lib/SimpleHTTPServer.py | 6 | 
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):  | 
