Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Lib/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,16 +1288,16 @@ def run_cgi(self):
env = env
)
if self.command.lower() == "post" and nbytes > 0:
cursize = 0
data = self.rfile.read(min(nbytes, _MIN_READ_BUF_SIZE))
while (len(data) < nbytes and len(data) != cursize and
cursize = min(nbytes, _MIN_READ_BUF_SIZE)
data = self.rfile.read(cursize)
while (len(data) == cursize < nbytes and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

len(data) == cursize means that we're expecting that cursize bytes of the data arrive over the socket simultaneously, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and this assumption was incorrect. There was another bug in the old code -- it did not work on Linux without fork(), because read(n) could return less than n bytes. #119455 fixed it, and we need to preserve this fix. I restored that code and try another approach -- using non-zero timeout.

select.select([self.rfile._sock], [], [], 0)[0]):
cursize = len(data)
# This is a geometric increase in read size (never more
# than doubling our the current length of data per loop
# iteration).
delta = min(cursize, nbytes - cursize)
data += self.rfile.read(delta)
cursize += delta
else:
data = None
# throw away additional data [see bug #427345]
Expand Down
Loading