[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-04-03 Thread Matt Eaton
Matt Eaton added the comment: Wanted to check in on this to see if there was any feedback by any community or core members? -- ___ Python tracker

[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-03-31 Thread Matt Eaton
Matt Eaton added the comment: Adding some core team members to the nosy list to get their take on this as well. -- nosy: +berker.peksag, eric.smith ___ Python tracker

[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-03-30 Thread Matt Eaton
Matt Eaton added the comment: I agree with you in regards to the statement, "Apache's redirect can be turned off, whereas this can't." That is why my first thought would be to try and control this response to the client a bit better by providing a variable max-age.

[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-03-30 Thread Oliver Urs Lenz
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

[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-03-30 Thread Matt Eaton
Matt Eaton added the comment: It looks like the 301 redirect is in place to emulate the behavior that Apache provides when it runs into a trailing slash. This is observed when this condition is met: parts = urllib.parse.urlsplit(self.path) if not

[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-03-30 Thread Oliver Urs Lenz
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):

[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-03-30 Thread Oliver Urs Lenz
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

[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-03-30 Thread Matt Eaton
Matt Eaton added the comment: Oliver, A possible option that would work for both the client side caching and the server would be to pass back a Cache-Control header with a max-age attached when the 301 is returned. I am thinking something like this: if

[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-03-29 Thread Oliver Urs Lenz
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