Hi Daniel,

I faced this same issue when writing ControlTower. When a request gets handed off to the application does depend on the server in question. Mongrel waits for the entire body to be received first (even though it uses a tempfile). Passenger, on the other hand, does not wait (at least, it didn't the last time I tested it). Passenger also does not directly use a tempfile, but rather a custom request body class. If you wanted to test directly, have a look at Net::HTTP using body_stream (there seems to be some info you might use here: http://stackoverflow.com/questions/213613/buffered-multipart-form-posts-in-ruby).

Cheers,

Josh

On Wed, Apr 13, 2011 at 3:17 AM, Daniel Abrahamsson <hamsson@gmail.com> wrote:
Hi,

I am working on a server that deals with large file uploads (currently built upon Rails, with a Metal taking care of the uploads). According to the rack-specification:
"... handler developers must buffer the input data into some rewindable object if the underlying input stream is not rewindable".

For Passenger and Mongrel, this means a temp file is created for the request (at least for requests as big as those I am dealing with).

Now, my question is, does Rack wait until all data from the client has been read to a tempfile before passing on control to the Rack app (in this case, Rails)? Or does it pass on control directly, and block if the application reads data faster than the client is sending it?

After some initial testing, it appears to me that the former is the case. Can anyone give me advice on how to test this? Perhaps it depends on the web server used? Perhaps on the framework?

Thank you in advance for any advance or clarification on this matter.

//Daniel