Message4876
Logged In: YES
user_id=228025
I have a possible fix, at least when the server is running on
Windows. As suggested previously, the key is to read the
bytes beyond the content-length, but without blocking. Steve
Holden suggested I use select, which seems simpler than
another solution which is to make the socket non-blocking,
then attempting to read 2 bytes of data within a try/except
block.
The solution below just loops with select.select
if self.command.lower() == "post" and nbytes > 0:
data = self.rfile.read(nbytes)
fi.write(data)
# now throw away data past Content-length
while select.select([self.rfile._sock], [], [], 0)[0] !=
[]:
waste = self.rfile._sock.recv(1)
fi.close()
This is slightly verbose. The two additional lines go below the
fi.write statement on line 247 of CGIHTTPServer.py, line 248 if
you count the import select statement that needs to be
added at the top of the file.
I have only tested this on Windows since the server code is
Windows-specific. I do not know if a server running on Unix
suffers this same problem. I verified that POST works
correctly from the following browsers on Windows 2000: IE
5.5, Opera 6.0.4, and Netscape 4.7. Only IE sends the extra
CR/LF, Opera and Netscape do not.
ka |
|
Date |
User |
Action |
Args |
2007-08-23 13:54:38 | admin | link | issue427345 messages |
2007-08-23 13:54:38 | admin | create | |
|