diff --git a/core/core.services.yml b/core/core.services.yml index 8fe29d2..c596086 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -609,12 +609,8 @@ services: http_kernel.basic: class: Symfony\Component\HttpKernel\HttpKernel arguments: ['@event_dispatcher', '@controller_resolver', '@request_stack'] - http_negotiation.format_negotiator: - class: Drupal\Core\ContentNegotiation - private: true http_middleware.negotiation: class: Drupal\Core\StackMiddleware\NegotiationMiddleware - arguments: ['@http_negotiation.format_negotiator'] tags: - { name: http_middleware, priority: 400 } http_middleware.reverse_proxy: diff --git a/core/lib/Drupal/Core/ContentNegotiation.php b/core/lib/Drupal/Core/ContentNegotiation.php deleted file mode 100644 index 08c8ab0..0000000 --- a/core/lib/Drupal/Core/ContentNegotiation.php +++ /dev/null @@ -1,34 +0,0 @@ -. - if ($request->get('ajax_iframe_upload', FALSE)) { - return 'iframeupload'; - } - - if ($request->query->has('_format')) { - return $request->query->get('_format'); - } - - // Do HTML last so that it always wins. - return 'html'; - } -} diff --git a/core/lib/Drupal/Core/ContentNegotiationInterface.php b/core/lib/Drupal/Core/ContentNegotiationInterface.php deleted file mode 100644 index 43f9850..0000000 --- a/core/lib/Drupal/Core/ContentNegotiationInterface.php +++ /dev/null @@ -1,30 +0,0 @@ -app = $app; - $this->negotiator = $negotiator; } /** @@ -62,7 +51,7 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = } // Determine the request format using the negotiator. - $request->setRequestFormat($this->negotiator->getContentType($request)); + $request->setRequestFormat($this->getContentType($request)); return $this->app->handle($request, $type, $catch); } @@ -80,5 +69,32 @@ public function registerFormat($format, $mime_type) { $this->formats[$format] = $mime_type; return $this; } + + /** + * Gets the normalized type of a request. + * + * The normalized type is a short, lowercase version of the format, such as + * 'html', 'json' or 'atom'. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * The request object from which to extract the content type. + * + * @return string + * The normalized type of a given request. + */ + public function getContentType(Request $request) { + // AJAX iframe uploads need special handling, because they contain a JSON + // response wrapped in