diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-08-05 23:58:12 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-05 13:44:37 +0200 |
commit | 3088b4f84f802fb84c4750ce25d8fe57c6c0a79e (patch) | |
tree | 8dfe8d05a351b470901d5ed6652305566b8836c1 /actionpack/lib | |
parent | 8958f332bbb552e87fd9f8c78dd11bdeab7897fc (diff) | |
download | rails-3088b4f84f802fb84c4750ce25d8fe57c6c0a79e.tar.gz rails-3088b4f84f802fb84c4750ce25d8fe57c6c0a79e.tar.bz2 rails-3088b4f84f802fb84c4750ce25d8fe57c6c0a79e.zip |
raise error on invalid HTTP methods or :head passed with :via in routes
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index f52fb91e97..d53c10e5f3 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -898,6 +898,15 @@ module ActionDispatch return self end + via = Array.wrap(options[:via]).map(&:to_sym) + if via.include?(:head) + raise ArgumentError, "HTTP method HEAD is invalid in route conditions. Rails processes HEAD requests the same as GETs, returning just the response headers" + end + + unless (invalid = via - HTTP_METHODS).empty? + raise ArgumentError, "Invalid HTTP method (#{invalid.join(', ')}) specified in :via" + end + on = options.delete(:on) if VALID_ON_OPTIONS.include?(on) args.push(options) |