Failure when posting an XML file to a rails metal app

I'm trying to write some rails metal code to handle a large XML file post, but I'm receiving a 500 from my server. If I use a POST but don't provide a file to upload, everything works and I receive a 200 response, but if I provide a file (the -d flag with curl), I receive a 500. Here's the curl command I'm using:

curl -siX POST http://large_file_tester/uploader -d @/home/mike/tmp/Product\ Upload\ Example\ XMLs/products.1000.xml --header "Content-Type: application/xml"

and the response:

HTTP/1.1 100 Continue

HTTP/1.1 500 Internal Server Error Server: Apache/2.2.11 (Ubuntu) Phusion_Passenger/3.0.7 Vary: Accept-Encoding Content-Length: 646 Connection: close Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>500 Internal Server Error</title> </head><body> <h1>Internal Server Error</h1> <p>The server encountered an internal error or misconfiguration and was unable to complete your request.</p> <p>Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.</p> <p>More information about this error may be available in the server error log.</p> <hr> <address>Apache/2.2.11 (Ubuntu) Phusion_Passenger/3.0.7 Server at large_file_tester Port 80</address> </body></html>

here's my apache error log:

[ pid=31236 thr=140090706884944 file=ext/apache2/Hooks.cpp:865 time=2011-05-09 17:08:44.35 ]: Unexpected error in mod_passenger: An error occured while sending the request body to the request handler: Broken pipe (32)   Backtrace:      (empty)

and here's the rails metal code:

# Allow the metal piece to run in isolation require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)

class Uploader   def self.call(env)     if env["PATH_INFO"] =~ /^\/uploader/       request = Rack::Request.new(env)       if request.post?         RAILS_DEFAULT_LOGGER.warn("UPLOAD RECEIVED. params: #{request.params.inspect}")         return [200,{"Content-Type" => "text/html"},["Upload success"]]       end       return [200, {"Content-Type" => "text/html"}, ["Hello, World!"]]     else       return[404, {"Content-Type" => "text/html"}, ["Not Found"]]     end   end end

Anyone have any suggestions? Thanks,

Mike

To really get to the bottom of it we’ll need to see your rails error logs, but one thing you can try is using --data-binary instead of -d in your curl command line. That’s tripped me up on many occasions working with XML.

-David