New submission from Oliver Urs Lenz :
SimpleHTTPRequestHandler.send_head() has this bit:
if os.path.isdir(path):
parts = urllib.parse.urlsplit(self.path)
if not parts.path.endswith('/'):
# redirect browser - doing basically what a
Oliver Urs Lenz added the comment:
That would definitely take the sting out of that permanent redirect. But I am
still wondering why we redirect at all. Why not leave redirects to the user and
do:
if os.path.isdir(path):
if not path.endswith('/'):
path = path + '/
Oliver Urs Lenz added the comment:
In fact, since we use os.path.join, we could remove that condition altogether:
if os.path.isdir(path):
for index in "index.html", "index.htm":
index = os.path.join(path, index)
if os.path.exists(index):
Oliver Urs Lenz added the comment:
Yes, but Apache's redirect can be turned off, whereas this can't, so it seems
unnecessarily limiting to force this on users. Note that most of the motivation
given by Apache doesn't apply here: with my proposed simplification, both types
o
Oliver Urs Lenz added the comment:
Slightly tangential, but it would be great if the documentation of lstrip() and
rstrip() could include an equivalent definition in terms of re.sub(), e.g.:
lstrip(foo) == re.sub(r'(?u)\A\s*', '', foo)
rstrip(foo) == re.sub(r'