Package wsgitools :: Module middlewares :: Class ContentLengthMiddleware
[hide private]
[frames] | no frames]

Class ContentLengthMiddleware

source code


Guesses the content length header if possible.


Note: The application used must not use the write callable returned by start_response.

Instance Methods [hide private]
 
__init__(self, app, maxstore=0)
Wraps wsgi application app.
source code
 
__call__(self, environ, start_response)
wsgi interface
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, app, maxstore=0)
(Constructor)

source code 

Wraps wsgi application app. If the application returns a list, the total length of strings is available and the content length header is set unless there already is one. For an iterator data is accumulated up to a total of maxstore bytes (where maxstore=() means infinity). If the iterator is exhaused within maxstore bytes a content length header is added unless already present.

Parameters:
  • maxstore (int or ())
Overrides: object.__init__

Note: that setting maxstore to a value other than 0 will violate the wsgi standard