Package cherrypy :: Module _cpreqbody :: Class SizedReader
[hide private]
[frames] | no frames]

Class SizedReader

source code

Instance Methods [hide private]
 
__init__(self, fp, length, maxbytes, bufsize=8192, has_trailers=False) source code
 
read(self, size=None, fp_out=None)
Read bytes from the request body and return or write them to a file.
source code
 
readline(self, size=None)
Read a line from the request body and return it.
source code
 
readlines(self, sizehint=None)
Read lines from the request body and return them.
source code
 
finish(self) source code
Method Details [hide private]

read(self, size=None, fp_out=None)

source code 

Read bytes from the request body and return or write them to a file.

A number of bytes less than or equal to the 'size' argument are read off the socket. The actual number of bytes read are tracked in self.bytes_read. The number may be smaller than 'size' when 1) the client sends fewer bytes, 2) the 'Content-Length' request header specifies fewer bytes than requested, or 3) the number of bytes read exceeds self.maxbytes (in which case, 413 is raised).

If the 'fp_out' argument is None (the default), all bytes read are returned in a single byte string.

If the 'fp_out' argument is not None, it must be a file-like object that supports the 'write' method; all bytes read will be written to the fp, and None is returned.