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
Date: Mon, 09 May 2011 07:24:35 GMT
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

500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Apache/2.2.11 (Ubuntu) Phusion_Passenger/3.0.7 Server at large_file_tester Port 80

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs