[Web-SIG] [extension] x-wsgiorg.flush

Manlio Perillo manlio_perillo at libero.it
Thu Oct 4 16:10:39 CEST 2007

Graham Dumpleton ha scritto:
> [...]
>> The idea was to allow an application to change its mind about the
>> headers until it had committed to writing data.  That is, to allow
>> the application to do error handling for as long as possible before
>> the server has to do it.
> But once you have called start_response() you cant call it a second
> time to change the values so how could the application change its
> mind? 

In my implementation of WSGI for nginx, start_response setups the 
headers on the request object, but calls ngx_http_send_header only when 
the first not empty string is yielded.

This means that if an error occurs, the "old" headers are kept in the 
response (and sent to the client); nginx will simply change the status 
code to '500 INTERNAL ERROR'.

A solution can be to copy the headers in a temporary request object, but 
I don't know if this is possible.

Another solution is to setup the headers and call send_headers at the 
same time, but in this way it is no more possible to raise an exception 
when the application calls start_response with incorrect headers.

If I'm right this is the solution used by Apache mod_wsgi.


Regards  Manlio Perillo

More information about the Web-SIG mailing list