Message346294
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... |
|
Date |
User |
Action |
Args |
2019-06-22 19:53:17 | shajianrui | set | recipients:
+ shajianrui, georg.brandl, vsbogd |
2019-06-22 19:53:17 | shajianrui | set | messageid: <1561233197.61.0.956417633044.issue37301@roundup.psfhosted.org> |
2019-06-22 19:53:17 | shajianrui | link | issue37301 messages |
2019-06-22 19:53:17 | shajianrui | create | |
|