[mod_python] sending headers directly to the client

Mike Looijmans nlv11281 at natlab.research.philips.com
Mon May 15 02:00:41 EDT 2006


First explain what is so special about your request that you cannot just 
send out regular data and have to delay sending the response headers?

Awaiting your reply - could a simple (periodic) redirect solve your problem?


Mike Looijmans
Philips Natlab / Topic Automation


Stefan Wehr wrote:
> Hi all,
> 
> I need to send headers directly to the client; that is, before
> mod_python sends its headers (I know that I have to handle the status
> line specially).
> 
> Background: I need to detect when the user hits the 'Cancel' button of
> the browser. The only reliable way to do this seems to send something
> periodically to the client. My idea is now to send dummy headers to
> the client until the possibly long running HTML code generating
> function is finished. Then I stop sending dummy headers and send the
> HTML code to the client. If the client hits 'Cancel' while the
> HTML code generating function is running, I'm able to detect this
> because I get some kind of error when sending a dummy header.
> 
> The problem is now: how can I send the dummy headers?
> 
> I cannot use 'req.write' because this flushes all headers (note that
> some headers can be set only *after* HTML has been generated).  My
> idea was then to use 'req.connection.write'. The problem with this
> approach is that this function does *not* trigger an error if the
> connection is closed. I also fiddled around with the
> 'req.connection.aborted' field without success.
> 
> Any help would be greatly appreciated.
> 
> Cheers, Stefan
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
> 



More information about the Mod_python mailing list