# POST with huge HTTP body

**URL:** <https://www.ruby-forum.com/t/post-with-huge-http-body/117262>\
**Category:** Mongrel\
**Created:** [October 15, 2007, 2:01pm UTC](https://www.ruby-forum.com/t/post-with-huge-http-body/117262 "2007-10-15T14:01:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [October 15, 2007, 2:01pm UTC](https://www.ruby-forum.com/t/post-with-huge-http-body/117262/1 "2007-10-15T14:01:11Z")

</div>

Hi,

I found the following page describing how to stream data from the  
server to the client:

[http://api.rubyonrails.com/classes/ActionController/Streaming.html](http://api.rubyonrails.com/classes/ActionController/Streaming.html)

I want to do the opposite, streaming data from the client to the server,  
letting the controller saving the data while it’s being received.  
In particular, I want to upload large files to the RailsDav  
([http://www.liverail.net/railsdav](http://www.liverail.net/railsdav)) plugin, without having to store  
the entire file in memory during the operation.

This seems to be a Mongrel problem, so I started looking at this plugin:

[http://mongrel.rubyforge.org/docs/upload\_progress.html](http://mongrel.rubyforge.org/docs/upload_progress.html)

How do I get Mongrel to store the incoming POST data in a tempfile,  
passing a handler to that file as the raw\_post field in the Rails  
request?  
Is it even possible?  
How is the “request” parameter to the process() method related to the  
“request” object in the Rails controllers?

/Daniel

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [October 15, 2007, 2:49pm UTC](https://www.ruby-forum.com/t/post-with-huge-http-body/117262/2 "2007-10-15T14:49:50Z")

</div>

On 10/15/07, Daniel B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want to do the opposite, streaming data from the client to the server,  
> letting the controller saving the data while it’s being received.  
> In particular, I want to upload large files to the RailsDav  
> ([http://www.liverail.net/railsdav](http://www.liverail.net/railsdav)) plugin, without having to store  
> the entire file in memory during the operation.
> 
> This seems to be a Mongrel problem, […]

I don’t have the solution to your problem, but I think you are looking  
in  
the wrong place.

Unless you plan to have mongrel listening on a public port, this is not  
a  
mongrel problem. The standard way to use mongrel, with Rails or not, is  
to  
set up a few of them behind a reverse proxy like nginx or  
apache+mod\_proxy\_balancer. In those cases, the proxy will not forward  
the  
data to mongrel before it has received it all, and once it has all the  
data,  
the latency between nginx and mongrel is negligible.

On the other hand, the reverse proxy (I’m only speaking from experience  
with  
nginx here) saves the data to file while it is receiving it. I think  
you  
should look for a solution that lets nginx pass the path to that file to  
mongrel rather than sending the data again. I believe I have read about  
such a solution on this very list a few months ago.

So, not the help you wanted, but I hope it leads you in the right  
direction. Well, if you actually intend to have mongrel face the  
public,  
then just forget what I said.

Good luck!

/David

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [October 15, 2007, 9:33pm UTC](https://www.ruby-forum.com/t/post-with-huge-http-body/117262/3 "2007-10-15T21:33:40Z")

</div>

At Mon, 15 Oct 2007 14:00:20 +0200,  
“Daniel B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> received. In particular, I want to upload large files to the  
> RailsDav ([http://www.liverail.net/railsdav](http://www.liverail.net/railsdav)) plugin, without having  
> to store the entire file in memory during the operation.
> 
> This seems to be a Mongrel problem, so I started looking at this plugin:
> 
> [http://mongrel.rubyforge.org/docs/upload\_progress.html](http://mongrel.rubyforge.org/docs/upload_progress.html)
> 
> How do I get Mongrel to store the incoming POST data in a tempfile,  
> passing a handler to that file as the raw\_post field in the Rails request?  
> Is it even possible?

Hi Daniel,

Mongrel is going to put a large POSTed body into a tempfile. Examine  
the mongrel.rb file around line 220. In this case your request.body is  
going to be a File object. Why do you think that there is a mongrel  
problem here? See also what Tim K. said in this thread.

> How is the “request” parameter to the process() method related to  
> the “request” object in the Rails controllers?

request in mongrel (as sent to process) is an instance of  
Mongrel::HttpRequest. In Rails it is an instance of  
ActionController::CgiRequest.

best,  
Erik Hetzner  
;; Erik Hetzner, California Digital Library  
;; gnupg key id: 1024D/01DB07E3
