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 shajianrui
Recipients georg.brandl, shajianrui, vsbogd
Date 2019-06-22.19:53:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561233197.61.0.956417633044.issue37301@roundup.psfhosted.org>
In-reply-to
Content
Sorry for replying so late, and thank you very much for your reply and explanation.

At first reply to you last post: I think at least in the non-unix environment, the CGIHTTPRequestHandler read the whole(expected) data from rfile and then transfer it to the CGI script.

And considering the code for Unix environment, I dont think to set the rbufsize to -1 is a good idea. I prefer a safer way: to do a read() loop and read until nbytes received. It is much slower but more compatible. Like this:

            if self.command.lower() == "post" and nbytes > 0:
                #data = self.rfile.read(nbytes)                     #Original code at line 1199
                databuf = bytearray(nbytes)
                datacount = 0
                while datacount + 1 < nbytes:
                    buf = self.rfile.read(self.request.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF))    #You can set your number.
                    if len(buf) == 0:            
                        print("Connection closed before nbytes reached.")
                        break
                    for i in range(len(buf)):
                        databuf[datacount] = buf[i]
                        datacount += 1
                        if datacount == nbytes:
                            break
                data = bytes(databuf)

This code is only for explanation... Not for use...
History
Date User Action Args
2019-06-22 19:53:17shajianruisetrecipients: + shajianrui, georg.brandl, vsbogd
2019-06-22 19:53:17shajianruisetmessageid: <1561233197.61.0.956417633044.issue37301@roundup.psfhosted.org>
2019-06-22 19:53:17shajianruilinkissue37301 messages
2019-06-22 19:53:17shajianruicreate