Package turbogears :: Package filters :: Module safemultipart :: Class MultipartWrapper

Class MultipartWrapper

source code

object --+
         |
        MultipartWrapper

Wraps a file-like object, returning '' when Content-Length is reached.

The cgi module's logic for reading multipart MIME messages doesn't allow the parts to know when the Content-Length for the entire message has been reached, and doesn't allow for multipart-MIME messages that omit the trailing CRLF (Flash 8's FileReference.upload(url), for example, does this). The read_lines_to_outerboundary function gets stuck in a loop until the socket times out.

This rfile wrapper simply monitors the incoming stream. When a read is attempted past the Content-Length, it returns an empty string rather than timing out (of course, if the last read *overlaps* the C-L, you'll get the last bit of data up to C-L, and then the next read will return an empty string).

Instance Methods
 
__init__(self, rfile, clen)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
read(self, size=None) source code
 
readline(self, size=None) source code
 
readlines(self, sizehint=0) source code
 
close(self) source code
 
__iter__(self) source code
 
next(self) source code

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

Properties

Inherited from object: __class__

Method Details

__init__(self, rfile, clen)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)