[Web-SIG] A more Twisted approach to async apps in WSGI

Ian Bicking ianb at colorstudy.com
Tue Oct 5 20:19:37 CEST 2004

James Y Knight wrote:
> However, interaction with middleware seems quite tricky here:
> - For input modifying middleware: I guess on_get would have to just 
> raise an exception if wsgi.input has been replaced. If the input stream 
> was iterable, an on_get callback could just be considered notice that 
> you can iterate the input stream once without blocking, assuming the 
> block boundary requirements were also in effect here. Then it would work 
> right even if the input stream was replaced. However, I think it might 
> be the case that middleware that wants to modify the input stream is so 
> rare, it doesn't really matter.

I think middleware would have to modify the input stream if it wanted to 
parse POST variables.  In that case, you might parse the input stream, 
while also constructing a replacement input stream for when the 
application tries to re-read the stream.  In effect the middleware wants 
to peek at the input stream.

I can't think of any other useful reasons to modify the input stream, 
but this one seems fairly reasonable.  For instance, a piece of 
middleware might try to detect a login attempt by looking for particular 
field names in the request.

Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org

More information about the Web-SIG mailing list