diff --git a/core/lib/Drupal/Core/Routing/MethodFilter.php b/core/lib/Drupal/Core/Routing/MethodFilter.php index d4687c3..64b8048 100644 --- a/core/lib/Drupal/Core/Routing/MethodFilter.php +++ b/core/lib/Drupal/Core/Routing/MethodFilter.php @@ -27,6 +27,11 @@ public function filter(RouteCollection $collection, Request $request) { foreach ($collection->all() as $name => $route) { $supported_methods = $route->getMethods(); + // If the GET method is allowed we also need to allow the HEAD method + // since HEAD is a GET method that doesn't return the body. + if (in_array('GET', $supported_methods)) { + $supported_methods[] = 'HEAD'; + } // A route not restricted to specific methods allows any method. If this // is the case, we'll also have at least one route left in the collection, diff --git a/core/modules/rest/src/Tests/UpdateTest.php b/core/modules/rest/src/Tests/UpdateTest.php index b2d84bc..93d3b6f 100644 --- a/core/modules/rest/src/Tests/UpdateTest.php +++ b/core/modules/rest/src/Tests/UpdateTest.php @@ -60,7 +60,7 @@ public function testPatchUpdate() { // header, this should throw the proper exception. $this->httpRequest($entity->toUrl(), 'PATCH', $serialized, 'none'); $this->assertResponse(Response::HTTP_UNSUPPORTED_MEDIA_TYPE); - $this->assertRaw('No route found that matches the Content-Type header.'); + $this->assertRaw('No route found that matches "Content-Type: none"'); // Update the entity over the REST API. $this->httpRequest($entity->urlInfo(), 'PATCH', $serialized, $this->defaultMimeType);