shajianrui <[email protected]> added the comment:
@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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37301>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com