Message346021
@vsbogd,Thank you for your reply. But I find another problem.
I derive a subclass from sockerserver.StreamRequestHandler, and set the rbufsize to 0(As CGIHTTPRequestHandler do), like this demo below:
testserver.py:
import socketserver
class TestRequestHandler(socketserver.StreamRequestHandler):
rbufsize = 0 ###simulate CGIHTTPRequestHandler
def handle(self):
while True:
data = self.rfile.read(65536*1024) ###client should send 65536*1024 bytes.
print(len(data))
if len(data) == 0:
print("Connection closed.")
break
s = socketserver.TCPServer(("0.0.0.0", 8001), TestRequestHandler)
s.serve_forever()
testclient.py:
import socket
data = bytearray(65536*1024)
for i in range(65536*1024):
data[i] = 64 #Whatever you set.
c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
c.connect(("127.0.0.1", 8001))
c.send(data)
The testserver.py can get the whole 65536*1024 data in every "data = self.rfile.read(65536*1024)" line. The normal output of testserver.py is:
testserver.py output:
67108864
0
Connection closed.
67108864
0
Connection closed.
In other words, this problem of "rfile.read(nbytes)" cannot be reproduce in this demo.
I dont know why, it seems this is not only the problem of the "rfile.read(nbytes)". I guess the CGIHTTPRequestHandler actually do something that make the "rfile.read(nbytes)" perform weirdly. However, I fail to find such a line in the code. |
|
Date |
User |
Action |
Args |
2019-06-19 05:22:40 | shajianrui | set | recipients:
+ shajianrui, georg.brandl, vsbogd |
2019-06-19 05:22:40 | shajianrui | set | messageid: <1560921760.31.0.921351747542.issue37301@roundup.psfhosted.org> |
2019-06-19 05:22:40 | shajianrui | link | issue37301 messages |
2019-06-19 05:22:40 | shajianrui | create | |
|