Forum: Ruby on Rails How do I read an HTTP PUT from a controller?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
52cb4115a870ff1942e7e1ae96f4306f?d=identicon&s=25 Tyler MacDonald (Guest)
on 2007-03-10 05:36
(Received via mailing list)
I've googled around a little bit and havent found anything useful. :-(
Has anybody written a rails controller that accepts HTTP PUT (DAV)
requests?
If so, do you have any pointers?

  Thanks,
    Tyler
8bc543795b502900b5333aea73ad5533?d=identicon&s=25 Eden Li (edenli)
on 2007-03-10 06:49
(Received via mailing list)
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

On Mar 10, 12:34 pm, Tyler MacDonald <google....@crackerjack.net>
52cb4115a870ff1942e7e1ae96f4306f?d=identicon&s=25 Tyler MacDonald (Guest)
on 2007-03-11 22:28
(Received via mailing list)
eden li <eden.li@gmail.com> wrote:
>     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
8bc543795b502900b5333aea73ad5533?d=identicon&s=25 Eden Li (edenli)
on 2007-03-12 02:16
(Received via mailing list)
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.

On Mar 12, 5:27 am, Tyler MacDonald <google....@crackerjack.net>
52cb4115a870ff1942e7e1ae96f4306f?d=identicon&s=25 Tyler MacDonald (Guest)
on 2007-03-13 18:59
(Received via mailing list)
eden li <eden.li@gmail.com> wrote:
> 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
This topic is locked and can not be replied to.