This project is archived and is in readonly mode.

#2658 ✓resolved
qoobaa

Internal server error after empty POST with XML content type

Reported by qoobaa | May 16th, 2009 @ 10:52 PM | in 2.x

The problem appears when you try to send empty POST request to RoR app using jQuery.

jQuery.post("/users", {})

It's a bit strange in jQuery but instead of: application/x-www-form-urlencoded it adds application/xml Content-Type header. The result is 500 Internal Server Error with following backtrace:

/!\ FAILSAFE /!\  2009-05-16 23:42:27 +0200
  Status: 500 Internal Server Error
  undefined method `split' for #<Mime::Type:0x000000025200d8>
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/mime_type.rb:206:in `method_missing'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/request.rb:51:in `media_type'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/request.rb:117:in `parseable_data?'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/request.rb:138:in `POST'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/request.rb:428:in `POST'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/request.rb:381:in `parameters'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/base.rb:1279:in `assign_shortcuts'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/base.rb:518:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/filters.rb:606:in `process_with_filters'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/rescue.rb:65:in `call_with_exception'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:91:in `rescue in dispatch'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:97:in `dispatch'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:111:in `_call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:82:in `block in initialize'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:29:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:29:in `block in call'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:9:in `cache'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:28:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/head.rb:9:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/params_parser.rb:15:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/rewindable_input.rb:25:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:93:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/reloader.rb:9:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/failsafe.rb:11:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11:in `block in call'
    <internal:prelude>:8:in `synchronize'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:106:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/rails/rack/static.rb:31:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `block in call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/rails/rack/log_tailer.rb:17:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/content_length.rb:13:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/handler/webrick.rb:46:in `service'
    /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
    /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
    /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

It's a minor issue, can be fixed in jQuery by adding data or forcing the Content-Type somehow. However it should be fixed to send a bit nicer response.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages