fix broken handling of unknown http methods

This commit is contained in:
Loren Norman 2020-09-17 15:33:27 -04:00 committed by Eugene Kenny
parent 533c5c3a53
commit 1f9a5dd36b
4 changed files with 14 additions and 1 deletions

View File

@ -137,6 +137,8 @@ module ActionDispatch
HTTP_METHOD_LOOKUP[method] = method.underscore.to_sym
}
alias raw_request_method request_method # :nodoc:
# Returns the HTTP \method that the application should see.
# In the case where the \method was overridden by a middleware
# (for instance, if a HEAD request was converted to a GET,

View File

@ -1,3 +1,9 @@
* Return a 405 Method Not Allowed response when a request uses an unknown HTTP method.
Fixes #38998.
*Loren Norman*
* Make railsrc file location xdg-specification compliant
`rails new` will now look for the default `railsrc` file at

View File

@ -47,7 +47,7 @@ module Rails
# Started GET "/session/new" for 127.0.0.1 at 2012-09-26 14:51:42 -0700
def started_request_message(request) # :doc:
'Started %s "%s" for %s at %s' % [
request.request_method,
request.raw_request_method,
request.filtered_path,
request.remote_ip,
Time.now.to_default_s ]

View File

@ -46,6 +46,11 @@ module ApplicationTests
assert_equal 404, last_response.status
end
test "renders unknown http methods as 405" do
request "/", { "REQUEST_METHOD" => "NOT_AN_HTTP_METHOD" }
assert_equal 405, last_response.status
end
test "uses custom exceptions app" do
add_to_config <<-RUBY
config.exceptions_app = lambda do |env|