[issue25433] whitespace in strip()/lstrip()/rstrip()

2018-04-11 Thread Oliver Urs Lenz

Oliver Urs Lenz <oliver.urs.l...@gmail.com> 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'(?u)\s*\Z', '', foo)

(Or whatever else is correct.)

--
nosy: +oulenz

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue25433>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2018-03-30 Thread Oliver Urs Lenz

Oliver Urs Lenz <oliver.urs.l...@gmail.com> 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 
of indices would still be served whether the path contains a trailing slash or 
not.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33181>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2018-03-30 Thread Oliver Urs Lenz

Oliver Urs Lenz <oliver.urs.l...@gmail.com> 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):
path = index
break

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33181>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2018-03-30 Thread Oliver Urs Lenz

Oliver Urs Lenz <oliver.urs.l...@gmail.com> 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 + '/'
for index in "index.html", "index.htm":
index = os.path.join(path, index)
if os.path.exists(index):
path = index
break

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33181>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2018-03-29 Thread Oliver Urs Lenz

New submission from Oliver Urs Lenz <oliver.urs.l...@gmail.com>:

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 apache does
self.send_response(HTTPStatus.MOVED_PERMANENTLY)

https://github.com/python/cpython/blob/521995205a2cb6b504fe0e39af22a81f785350a3/Lib/http/server.py#L676

I think there are two issues here:
1) why should the server return a redirect code here, and not (in the code that 
immediately follows) when it serves an index file?
2) code 301 (permanent redirect) is really unforgiving, browsers like Firefox 
and Chrome will permanently cache the redirect, making it essentially 
impossible to undo if you do not control the client, and not trivial even if 
you do. This will probably not change on the browser-side, general opinion 
seems to be that limited caching should either be specified in the response 
header or that a different redirect code should be sent back.
https://lists.w3.org/Archives/Public/ietf-http-wg/2017OctDec/thread.html#msg363

Therefore I would like to propose that preferably,
- no redirect code be sent back, or else that
- a different redirect code be sent back, or else that
- no-caching or a time limit be added to the header

(This may require that send_head check for index files instead)

--
components: Library (Lib)
messages: 314663
nosy: oulenz
priority: normal
severity: normal
status: open
title: SimpleHTTPRequestHandler shouldn't redirect to directories with code 301
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33181>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com