mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
raise error on invalid HTTP methods or :head passed with :via in routes
This commit is contained in:
parent
8958f332bb
commit
3088b4f84f
2 changed files with 10 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -718,7 +718,7 @@ class ResourcesTest < ActionController::TestCase
|
|||
set.draw do
|
||||
resources :messages do
|
||||
member do
|
||||
match :something, :via => :invalid
|
||||
match :something, :via => [:invalid, :get]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue