Avoid duplicating routes for HEAD requests.

Follow up to rails#15321

Instead of duplicating the routes, we can store the HEAD routes and
try to map them to the request first. If no match is found, we will
then map the HEAD request to the GET routes.