zlib, gzip and HTTP compression.

Michael Ströder michael at stroeder.com
Sat Jan 12 10:25:18 EST 2002


Alan Kennedy wrote:
> 
> rmunn at pobox.com (Robin Munn) wrote in message
> > I have no idea if this might be causing your problem, but print adds a
> > newline after whatever it prints. What happens if you use
> > sys.stdout.write() instead?
> 
> I tried that, but unfortunately to no avail.

See my other posting for the compression issues. But IMHO you should
never ever use print statements in web applications. It makes life
easier to use file objects from the very beginning (think of writing
simple wrappers for CGI-BIN, SimpleHTTPServer, FastCGI, mod_python,
etc.). It also makes it easier to pipe the output through other file
objects like gzip.GzipFile.

> When outputting the HTTP headers, they should be separated by CR-LF,
> or "\r\n" in a python string, so print is definitely doing the right
> thing there.

IMHO this depends on the underlying OS. You should output the line
separator '\r\n' manually in your application.

Ciao, Michael.



More information about the Python-list mailing list