id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,branch,branch_author,launchpad_bug
1873,Large File Uploads Fail,lennyg,,"resource.PostableResource doesn't seem able to handle file uploads much larger than 9M.  At 10M, the render() method is never entered.  Here is a code snippet that can be used to reproduce the error:

{{{
import os
from twisted.internet import reactor
from twisted.web2 import server, http, resource, channel
from twisted.web2 import http_headers, responsecode
from twisted.web2 import iweb, stream

SAVEDIR = ""/tmp""
READSIZE=8192

class UploadFile(resource.PostableResource):
    def render(self, ctx):
        request = iweb.IRequest(ctx)
        filename = request.files['filename'][0][0]
        file = request.files['filename'][0][2]

        filestream = stream.FileStream(file)
        dest = os.path.join(SAVEDIR,filename)
        destfile = os.fdopen(os.open(dest,
                os.O_WRONLY | os.O_CREAT | os.O_EXCL,
                0644), 'w', 0)
        stream.readIntoFile(filestream, destfile)

        msg = ""saved %s to %s"" % (filename, dest)
        print msg
        return http.Response(stream=""%s"" % msg)

class Toplevel(resource.Resource):
    addSlash = True
    def render(self, ctx):
        return http.Response(responsecode.OK,
                {'content-type': http_headers.MimeType('text', 'html')},
                ""Hello"")

    child_uploadfile = UploadFile()

if __name__ == ""__main__"":
    site = server.Site(Toplevel())
    reactor.listenTCP(1080, channel.HTTPFactory(site))
    reactor.run()


And here is an html form that can be used to test, with files of varying sizes:

<html>
    <form action=""http://localhost:1080/uploadfile""
            enctype=""multipart/form-data"" method=""post"">
        filename: <input type=""file"" name=""filename"">
        <input type=""submit"" value=""submit"">
    </form>
</html>
}}}

Programmatic clients (written in e.g. httplib) also get blocked upon writing only a few hunder KB if the file is larger than 10MB.",defect,closed,normal,Web2-Gold-Master,web2,wontfix,,,,,
