Jim Dabell
jim-mod-python at jimdabell.com
Thu Aug 12 20:53:28 EDT 2004
On Thursday 12 August 2004 18:03, Gregory (Grisha) Trubetskoy wrote: > On Thu, 12 Aug 2004, Jim Dabell wrote: > > Unfortunately, that just repeatedly calls req.write(), which doesn't give > > me the opportunity to perform any operations on the result before it is > > sent to the client, or even output additional headers afterwards. For > > instance, I can't find a way of producing a Content-Length header, or > > using content encoding to gzip the response body. > > You shouldn't need to set content length because it will be set by Apache > for you. Apache will decide wither to set it depending on the protocol > version used and whether the client accepts chunked encoding. Great! Is there a description of all the fixups Apache adds anywhere? > If you want to gzip the response, the proper way to do this in Apache 2.0 > would be by implementing a filter rather than a handler, there is actually > an example of how to do this in mod_python in the examples directory, > though you will probably be better off using something like mod_gzip. Thanks, that's useful to know and I'll probably use that, but Content-Length and gzip were just examples. I was really hoping for a clean way of getting the result of a PSP instead of it being automatically sent to the client; I'd rather not split my script up if it's not necessary. I'd use this buffer for such things as: * Generating an etag header based upon the template result. * Generating a header that showed how long the template transformation took. * Running the result through HTML Tidy. * Converting to XHTML where acceptable. * Providing a Content-MD5 header. Sure, all of these things can be hacked around, separated into filters or placed into templates, I just don't see the point when an output buffer would give a clean way of doing all this in a single handler, and I could leave the templates to simply be templates. -- Jim Dabell
|