[mod_python] strange behaviour with compressed response

Jim Gallacher jpg at jgassociates.ca
Wed Jan 3 09:24:35 EST 2007


m.banaouas wrote:
> Hi,
> 
>  >req.sendfile('c:/apache/htdocs/myfile.xml')
> In my real case, the response contain "dynamic" data built with database 
> extracted rows.
> So it's may be not the best thing to do (storing it first in a file).
> 
>  >       SetOutputFilter DEFLATE
> Now, it works finally! even without this directive.
> 
> In fact the right question would be:
> "what is the difference between req.write(bla) and return bla ?"

Very little. When you return something using mod_python.publisher, it 
still calls req.write() internally.

Perhaps the biggest difference is that mod_python.publisher calls 
req.write with flush=0, whereas the default is flush=1.

This could have implications concerning the setting of the 
Content-Length header versus use of Transfer-Encoding: chunked. (I'm not 
100% sure about that, but I have the idea that by not immediately 
flushing to the client Apache may be able to set the Content-Length header).

On the other hand, your client is using HTTP/1.0 which may introduce 
other complications. (IIRC HTTP/1.0 does not support Transfer-Encoding)

  > Firefox browser is certainly http-tolerant and can manage some
> "imperfect" http dialogs.
> Of course, the problem I meet could be caused by bad implementation in 
> MyHttpClient side.
> But the same comp in the sames conditions fails when response is 
> "written" and works fine when the response is "returned", bizare non ?

I suspect it may be some implementation detail in your client.

Jim


More information about the Mod_python mailing list