This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vsbogd
Recipients vsbogd
Date 2019-06-16.03:50:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1560657037.14.0.131884305953.issue37301@roundup.psfhosted.org>
In-reply-to
Content
Analysis:

self.rfile.read(nbytes)

https://github.com/python/cpython/blob/3a1d50e7e573efb577714146bed5c03b9c95f466/Lib/http/server.py#L1207

Doesn't read full content of the file but only first chunk because self.rfile is not BufferedIO instance. In fact it is SocketIO instance. The reason is that CGIHTTPServer sets rbufsize to 0:

    # Make rfile unbuffered -- we need to read one line and then pass
    # the rest to a subprocess, so we can't use buffered input.
    rbufsize = 0

https://github.com/python/cpython/blob/3a1d50e7e573efb577714146bed5c03b9c95f466/Lib/http/server.py#L975-L977

So the minimal fix is to set rbufsize back to -1 again. This fix requires one more change, because code below:

            # throw away additional data [see bug #427345]
            while select.select([self.rfile._sock], [], [], 0)[0]:
                if not self.rfile._sock.recv(1):
                    break

https://github.com/python/cpython/blob/3a1d50e7e573efb577714146bed5c03b9c95f466/Lib/http/server.py#L1210-L1213

expects self.rfile instance to be SocketIO. 

This could be fixed by replacing this code by:


So the minimal fix is to set rbufsize back to -1 again. This fix requires one more change, because code below:

            # throw away additional data [see bug #427345]
            while select.select([self.rfile], [], [], 0)[0]:
                if not self.rfile.read(1):
                    break

like it is implemented in another branch of the condition check:

https://github.com/python/cpython/blob/3a1d50e7e573efb577714146bed5c03b9c95f466/Lib/http/server.py#L1163-L1166
History
Date User Action Args
2019-06-16 03:50:37vsbogdsetrecipients: + vsbogd
2019-06-16 03:50:37vsbogdsetmessageid: <1560657037.14.0.131884305953.issue37301@roundup.psfhosted.org>
2019-06-16 03:50:37vsbogdlinkissue37301 messages
2019-06-16 03:50:36vsbogdcreate