diff --git a/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php b/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php index addfc2e8fc..ccdd99586e 100644 --- a/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php +++ b/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php @@ -117,7 +117,7 @@ protected function getContentType(Request $request) { return $request->query->get('_format'); } - if ($this->contentNegotiationConfig['respect_headers']['accept'] ?? FALSE) { + if ($this->contentNegotiationConfig['headers']['accept'] ?? FALSE) { $accept = AcceptHeader::fromString($request->headers->get('accept')); if (count($accept->all()) === 1 && $format = $request->getFormat($accept->first()->getValue())) { return $format; diff --git a/sites/default/default.services.yml b/sites/default/default.services.yml index baff7c5984..36e8f1782e 100644 --- a/sites/default/default.services.yml +++ b/sites/default/default.services.yml @@ -173,13 +173,14 @@ parameters: # Sets the Access-Control-Allow-Credentials header. supportsCredentials: false - # Configure HTTP content negotiation. + # Configure HTTP proactive content negotiation. # Read https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation # for more information about the topic in general. content_negotiation.config: - # Specify the headers by which response can vary. At present, `accept` is - # the only supported header. - # Note: These settings will only be used if - # `use_http_content_negotiation_headers` is set to TRUE via settings.php - respect_headers: - - 'accept' + # Note: These settings will only be used if `enable_content_negotiation` + # is set to TRUE via settings.php. After Drupal 9.0, this configuration will + # be used regardless. + enabled: true + # Specify the headers by which responses may vary. + headers: + accept: true