1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #19431 from hmarr/head-routing

Respect routing precedence for HEAD requests
This commit is contained in:
Rafael Mendonça França 2015-06-22 19:34:37 -03:00
commit 75b63de5ed
2 changed files with 4 additions and 4 deletions

View file

@ -121,7 +121,8 @@ module ActionDispatch
end
def match_head_routes(routes, req)
head_routes = match_routes(routes, req)
verb_specific_routes = routes.reject { |route| route.verb == // }
head_routes = match_routes(verb_specific_routes, req)
if head_routes.empty?
begin

View file

@ -3567,12 +3567,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
mount lambda { |env| [200, {}, [env['REQUEST_METHOD']]] }, at: '/'
end
# TODO: HEAD request should match `get /home` rather than the
# HEAD request should match `get /home` rather than the
# lower-precedence Rack app mounted at `/`.
head '/home'
assert_response :ok
#assert_equal 'test#index', @response.body
assert_equal 'HEAD', @response.body
assert_equal 'test#index', @response.body
# But the Rack app can still respond to its own HEAD requests.
head '/foobar'