Adam MilliganAdam Milligan
Rails requests missing the HTTP body
edit Posted by Adam Milligan on Saturday August 15, 2009 at 01:56PM

This is a bug in Rails that quite likely affects you, but which you've even more likely never experienced. I've posted it here for the benefit of the small number of people who will run into this problem and turn to Google for help.

In short, if you use Mongrel app servers (this may affect Passenger as well, I don't know), the first HTTP request to your Rails app after you restart your servers, or otherwise reload your environment, will have an empty HTTP body.

I say you've likely never experienced this because the majority of HTTP requests to your Rails app are likely GET requests, which always have empty HTTP bodies. After that first request everything will work just fine. Even if you're unlucky enough to receive a POST or a PUT request containing a body immediately after restart it will only fail once, which you could easily write off an an anomaly. You also won't see this behavior in your development environment, or any environment in which you use Mongrel as a web server rather than just an app server.

If you're interested in a patch for the bug, I've submitted one to Rails here.