Wraps a stream so that it doesn’t read more than n bytes. If the stream is exhausted and the caller tries to get more bytes from it
on_exhausted()is called which by default returns an empty string. The return value of that function is forwarded to the reader function. So if it returns an empty string
read()will return an empty string as well.
The limit however must never be higher than what the stream can output. Otherwise
readlines()will try to read past the limit.
Note on WSGI compliance
readlines()are not WSGI compliant because it passes a size argument to the readline methods. Unfortunately the WSGI PEP is not safely implementable without a size argument to
readline()because there is no EOF marker in the stream. As a result of that the use of
- stream – the stream to wrap.
- limit – the limit for the stream, must not be longer than what the string can provide if the stream does not end with EOF (like wsgi.input)
||Exhaust the stream.|
||What should happen if a disconnect is detected? The return value of this function is returned from read functions in case the client went away.|
||This is called when the stream tries to read past the limit.|
||Read size bytes or if size is not provided everything is read.|
||Reads one line from the stream.|
||Reads a file into a list of strings.|
||Returns the position of the stream.|