Brendan T O'Connor wrote: > Hi, > > I was having problems with the file upload demo on Windows with > Apache/CGI. Turns out that to safely upload binary files, you have to > get sys.stdin to be in binary mode, else it quits reading once it hits > the first null byte. Here's my patch to upload.py which seems to > solve it on windows at least -- are there any problems with this? I haven't tested the patch -- but I wanted to add that this hasn't been necessary on win32 when using Medusa or Twisted, because they both use StringIO to implement req.stdin. Setting binary-mode on stdin and stdout *might* be undesirable if Quixote is not running as a CGI application. I can't think of a killer case, but one might exist... (I might, e.g., be collecting data from a Web UI, and writing it out to stdout, piped to a file... odd but possible.) At the very least, it would be an unnecessary call for non-CGI processes. Perhaps it would be better to set these modes in the *CGI handler script instead of in upload.py? This might also make sense for FCGI/SCGI, so that the (perhaps small) overhead of the import and setmode() calls is not invoked every time a file is uploaded, but rather once when the streams are connected. -- Graham