[Zope-dev] opinion: speeding up large PUT uploads

Dieter Maurer dieter at handshake.de
Mon Apr 4 14:27:38 EDT 2005


Chris McDonough wrote at 2005-4-3 18:14 -0400:
> ...
>So in the common case, when a large file is uploaded via HTTP PUT (both
>DAV and external editor use PUT exclusively), here's what happens:
>
>- ZServer creates a tempfile T1 to hold the file body as it gets
>  pulled in.
>
>- When the request makes it to the publisher, processInputs is called
>  and it hands off tempfile T1 to FieldStorage.
>
>- FieldStorage reads the entire body and creates another tempfile
>  T2 (an exact copy of T1*, in the case of a PUT request).
>
>- T2 is eventually put into REQUEST['BODYFILE'].
>
>(*) At least I can't imagine a case where it's not an exact copy.
>
>This is costly on large uploads.  I'd like to change the top of the
>processInputs method to do this:
>
>if method == 'PUT':
>    # we don't need to do any real input processing if we are
>    # handling a PUT request.
>    self._file = self.stdin
>    return
>
>Can anyone think of a reason I shouldn't do this?

Even a "PUT" may get a multipart entity. At least, the HTTP specification
does not tell anything to the contrary.

Otherwise, (working) optimizations are of course welcome...

-- 
Dieter


More information about the Zope-Dev mailing list