[issue37301] CGIHTTPServer doesn't handle long POST requests
vsbogd
report at bugs.python.org
Mon Jun 17 05:52:41 EDT 2019
vsbogd <vsbogd at gmail.com> added the comment:
Yeah, I have seen this comment as well. As I see this code for the first time I am not very familiar with it.
It seems that this explanation is related to the case when non-Python CGI script is executed:
os.dup2(self.rfile.fileno(), 0)
os.dup2(self.wfile.fileno(), 1)
os.execve(scriptfile, args, env)
https://github.com/python/cpython/blob/3a1d50e7e573efb577714146bed5c03b9c95f466/Lib/http/server.py#L1176-L1178
On one hand the comment seems reasonable: as fileno is duped one cannot just read from it ahead of time. On the other hand few lines earlier one can see:
# throw away additional data [see bug #427345]
while select.select([self.rfile], [], [], 0)[0]:
if not self.rfile.read(1):
break
https://github.com/python/cpython/blob/3a1d50e7e573efb577714146bed5c03b9c95f466/Lib/http/server.py#L1163-L1166
which also seems like reading ahead of time.
My opinion this case should be tested after fix and if it works then fix can be applied without hesitation.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37301>
_______________________________________
More information about the Python-bugs-list
mailing list