wsgi.input for Transfer-Encoding: chunked; environ['wsgi.input'] is set to an instance of this class when the following conditions are met: 1. The user agent is speaking HTTP/1.1 2. The request specifies Transport-Encoding: chunked; see: http://mail.python.org/pipermail/web-sig/2004-September/000879.html Thinking out loud: 1. & 2. can not occur independently, Transfer-Encoding: chunked; is HTTP/1.1 only. What would an asynwsgi aware app look like ? if 'Transfer-Encoding' in environ: if TE_NOT_SUPPORTED_BY_THIS_APP: environ['CONNECTION']='close' ??? non-standard but easy start_response(, some_error) for chunk in environ['wsgi.input']: # v is on of ['', environ['wsgi.input'], response_chunk] # it it is the input instance the application has completely # consumed the current chunk and must not be resumed until # the next chunk is available. # # if its the empty string its a co-operative yield # otherwise v must be transmited fully to the client before # resuming the application. v = response = start_chunk(environ, chunk) yield v for v in response: yield v Keep-Alive vs close ? This implementation assumes that either: 1) The application will iterate over its input OR 2) The application will use read or readlines to consume its input. And that the application will do on of two things when there is no CONTENT_LENGTH in the environ: a) call input.read() with no parameters OR b) synthesize an error and set the Connection:close header. Strictly speaking pep-333 does not allow b) as it means the application/ middle ware is setting a hop-by-hop header. This server will allways honour an application or middle wares request for connection:close.