[Mongrel] max upload size!

Tim Kuijsten kuijsten at yahoo.com
Sat Mar 24 12:46:21 EDT 2007


As suggested in "max upload size?"
http://www.mail-archive.com/mongrel-users@rubyforge.org/msg02325.html
I created a plugin that disconnects (raises an error which
terminates the socket) if the specified content-length is higher
than 200 MB (by default). 

I don't know the behaviour if the specified content length is
different than the actual uploaded data or if no content-length
is given and chucked uploads are used.

I wanted to fix this by using the request_progress(params, clen,
total) method but clen represents the number of bytes that still
have to come in, not the number of received bytes.

How does mongrel deal with uploads when it does not know the
total content length?

And my second question:
Zed suggests in his post "and then attach that to the front of
your rails request". Currently my plugin raises an error and
disconnects the socket without send a reply at all (and the
Apache proxy keeps accepting incoming data making the user wait
till the upload is "completed" to discover it didn't upload). How
can I send an HTTP 413 and disconnect on request_begins. I tried
passing in the socket into request_begins as a second parameter
but I don't like to mess with the mongrel sources and rather keep
everything in the plugin.

I made a small writeup on my blog where you can also download the
plugin as a gem: http://slasaus.netsend.nl/articles/show/7

The solutions should get more user friendly by aborting the
upload from the client's perspective too, but at least it already
prevents full hard disks ;-)

Tim


 
____________________________________________________________________________________
Sucker-punch spam with award-winning protection. 
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html


More information about the Mongrel-users mailing list