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:
commit
75b63de5ed
2 changed files with 4 additions and 4 deletions
|
@ -121,7 +121,8 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
def match_head_routes(routes, req)
|
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?
|
if head_routes.empty?
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -3567,12 +3567,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
||||||
mount lambda { |env| [200, {}, [env['REQUEST_METHOD']]] }, at: '/'
|
mount lambda { |env| [200, {}, [env['REQUEST_METHOD']]] }, at: '/'
|
||||||
end
|
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 `/`.
|
# lower-precedence Rack app mounted at `/`.
|
||||||
head '/home'
|
head '/home'
|
||||||
assert_response :ok
|
assert_response :ok
|
||||||
#assert_equal 'test#index', @response.body
|
assert_equal 'test#index', @response.body
|
||||||
assert_equal 'HEAD', @response.body
|
|
||||||
|
|
||||||
# But the Rack app can still respond to its own HEAD requests.
|
# But the Rack app can still respond to its own HEAD requests.
|
||||||
head '/foobar'
|
head '/foobar'
|
||||||
|
|
Loading…
Reference in a new issue