[Mongrel] Upload progress size incorrect

Pete DeLaurentis pete at nextengine.com
Sat Feb 24 00:04:19 EST 2007

Hi guys,

I've hooked mongrel_upload_progress into our application, and it's  
working now, but I noticed what might be a small bug.

The size of the file as reported by Mongrel is slightly bigger than  
the actual file size (both on the source computer + when it's stored  
on the server).

This difference varies slightly each time, but seems to be in the  
neighborhood of 420 - 486 extra bytes.  My guess is that when Mongrel  
calculates the file size to give to upload progress, it doesn't strip  
out the HTTP header.

Here's the code snippet for the upload progress gem where the issue  
seems to be.  The content length is returning the wrong number.

class Upload < GemPlugin::Plugin "/handlers"
   include Mongrel::HttpHandlerPlugin


   def request_begins(params)
     upload_notify(:add, params, params 

I use this file size to ensure the upload completed successfully, but  
I have a workaround.  I'm doing Flash based upload, and I can get the  
file size from Flash and send it to the server before the upload  
starts.  But the all-server-side approach seems cleaner and more  

Small bug aside... this is a really cool gem ... it's letting me  
upload a file from one client and show the progress of the upload to  
other clients as they wait for the file.


Pete DeLaurentis
Lead Software Engineer
NextEngine, Inc.
pete at nextengine.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070223/77970548/attachment.html 

More information about the Mongrel-users mailing list