POST Body Truncated

Eric Wong normalperson at
Tue Oct 6 18:52:19 EDT 2009

Eric Wong <normalperson at> wrote:
> Chris Wanstrath <chris at> wrote:
> > On Tue, Oct 6, 2009 at 2:50 PM, Eric Wong <normalperson at> wrote:
> > 
> > > No worries, I'm working on a a reproducible test case.  Can you try
> > > and see if you're using curl's -F to POST, you _don't_ hit it?
> > 
> > `curl -F` does NOT trigger POST body truncation.
> Still trying to reproduce this, I think you're hitting a buffer boundary
> in nginx and triggering a bug in Unicorn::TeeInput somewhere.   You may
> be able to increase some userspace buffer sizes in nginx to
> workaround it until I (or somebody else) can fix it (hopefully very soon
> now).

OK, here's a workaround that should work for now.  I have to hit the
road in a few minutes but will be back on a computer in a few hours.

This only affects older Rails (and I'm supposed to still be supporting
1.2.x!) and its interaction with a wrapped CGI.stdinput somewhere is
going bad...

diff --git a/lib/unicorn/app/old_rails.rb b/lib/unicorn/app/old_rails.rb
index ba1260a..51bda52 100644
--- a/lib/unicorn/app/old_rails.rb
+++ b/lib/unicorn/app/old_rails.rb
@@ -14,6 +14,8 @@ module Unicorn; module App; end; end
 class Unicorn::App::OldRails
   def call(env)
+    env['rack.input'].each { |x| }
+    env['rack.input'].rewind
     cgi =

I'll have a better diagnosis+fix+test when I return.
Sorry for the bug :x

Eric Wong

More information about the mongrel-unicorn mailing list