Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect routing precedence for HEAD requests #19431

Merged
merged 1 commit into from
Jun 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion actionpack/lib/action_dispatch/journey/router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def find_routes req
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
Expand Down
5 changes: 2 additions & 3 deletions actionpack/test/dispatch/routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3492,12 +3492,11 @@ def test_head_fetch_with_mount_on_root
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'
Expand Down