How do I read an HTTP PUT from a controller?

I've googled around a little bit and havent found anything useful. :frowning: Has anybody written a rails controller that accepts HTTP PUT (DAV) requests? If so, do you have any pointers?

  Thanks,     Tyler

Rails can accept pretty much any HTTP request -- just check the request.method accessor. Rails provides a special test for put that makes things really succinct.

  def action     if request.put?       body = request.raw_post       # do something with body     else       redirect_to :action => "error"     end   end

Great, so this code works with some uploaders (like curl), but other uploaders (like the one from upload.thinfile.com), which work with PHP, give me this error in ruby... (or just fail silently if I use CGI instead of FastCGI)... any ideas?

You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occured while evaluating nil.include? /var/www/public/../config/../vendor/rails/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb:49:in `parse_request_parameters' /var/www/public/../config/../vendor/rails/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb:47:in `each' /var/www/public/../config/../vendor/rails/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb:47:in `parse_request_parameters' /var/www/public/../config/../vendor/rails/actionpack/lib/action_controller/cgi_process.rb:71:in `request_parameters' /var/www/public/../config/../vendor/rails/actionpack/lib/action_controller/request.rb:13:in `parameters' /var/www/public/../config/../vendor/rails/actionpack/lib/action_controller/session_management.rb:122:in `set_session_options_without_components' /var/www/public/../config/../vendor/rails/actionpack/lib/action_controller/components.rb:178:in `set_session_options' /var/www/public/../config/../vendor/rails/actionpack/lib/action_controller/session_management.rb:116:in `process' /var/www/public/../config/../vendor/rails/railties/lib/dispatcher.rb:38:in `dispatch' /var/www/public/../config/../vendor/rails/railties/lib/fcgi_handler.rb:150:in `process_request' /var/www/public/../config/../vendor/rails/railties/lib/fcgi_handler.rb:54:in `process!' /usr/lib/ruby/1.8/fcgi.rb:612:in `each_cgi' /usr/lib/ruby/1.8/fcgi.rb:609:in `each' /usr/lib/ruby/1.8/fcgi.rb:609:in `each_cgi' /var/www/public/../config/../vendor/rails/railties/lib/fcgi_handler.rb:53:in /`process!' /var/www/public/../config/../vendor/rails/railties/lib/fcgi_handler.rb:23:in /`process!' /var/www/public/dispatch.fcgi:26

  Thanks,     Tyler

I remember running into this same exception when I sent raw XML with ampersands to my rails 1.1.6 controllers. You'll need to hand patch that line by placing "next if key.nil? || key.empty?" before line 48 of vendor/rails/actionpack/lib/action_controller/cgi_ext/ cgi_methods.rb.

OR you could just upgrade to 1.2.2 -- I think this has been fixed by now.

Upgrading to 1.2.2 did indeed fix the problem! Thanks, eden!

  Cheers,   Tyler