diff --git a/core/lib/Drupal/Core/ContentNegotiation.php b/core/lib/Drupal/Core/ContentNegotiation.php
index 1074b81..24a7939 100644
--- a/core/lib/Drupal/Core/ContentNegotiation.php
+++ b/core/lib/Drupal/Core/ContentNegotiation.php
@@ -12,19 +12,10 @@
 /**
  * Provides content negotation based upon query parameters.
  */
-class ContentNegotiation {
+class ContentNegotiation implements ContentNegotiationInterface {
 
   /**
-   * 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.
+   * {@inheritdoc}
    */
   public function getContentType(Request $request) {
     // AJAX iframe uploads need special handling, because they contain a JSON
diff --git a/core/lib/Drupal/Core/ContentNegotiationInterface.php b/core/lib/Drupal/Core/ContentNegotiationInterface.php
new file mode 100644
index 0000000..43f9850
--- /dev/null
+++ b/core/lib/Drupal/Core/ContentNegotiationInterface.php
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\Core\ContentNegotiationInterface.
+ */
+
+namespace Drupal\Core;
+
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * Provides content negotiation based upon query parameters.
+ */
+interface ContentNegotiationInterface {
+
+  /**
+   * 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);
+}
diff --git a/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php b/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php
index 3b0bf76..5330cf7 100644
--- a/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php
+++ b/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\Core\StackMiddleware;
 
-use Drupal\Core\ContentNegotiation;
 use Drupal\Core\ContentNegotiationInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -29,7 +28,7 @@ class NegotiationMiddleware implements HttpKernelInterface {
   /**
    * The content negotiator.
    *
-   * @var \Drupal\Core\ContentNegotiation
+   * @var \Drupal\Core\ContentNegotiationInterface
    */
   protected $negotiator;
 
@@ -45,10 +44,10 @@ class NegotiationMiddleware implements HttpKernelInterface {
    *
    * @param \Symfony\Component\HttpKernel\HttpKernelInterface $app
    *   The wrapper HTTP kernel
-   * @param \Drupal\Core\ContentNegotiation $negotiator
+   * @param \Drupal\Core\ContentNegotiationInterface $negotiator
    *   The content negotiator.
    */
-  public function __construct(HttpKernelInterface $app, ContentNegotiation $negotiator) {
+  public function __construct(HttpKernelInterface $app, ContentNegotiationInterface $negotiator) {
     $this->app = $app;
     $this->negotiator = $negotiator;
   }
diff --git a/core/modules/system/tests/modules/accept_header_routing_test/src/AcceptHeaderMiddleware.php b/core/modules/system/tests/modules/accept_header_routing_test/src/AcceptHeaderMiddleware.php
deleted file mode 100644
index 51daedb..0000000
--- a/core/modules/system/tests/modules/accept_header_routing_test/src/AcceptHeaderMiddleware.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\accept_header_routing_test\AcceptHeaderMiddleware.
- */
-
-namespace Drupal\accept_header_routing_test;
-
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\HttpKernelInterface;
-
-/**
- * Example implementation of accept header based content negotation.
- */
-class AcceptHeaderMiddleware implements HttpKernelInterface {
-
-  /**
-   * Constructs a new AcceptHeaderMiddleware instance.
-   *
-   * @param \Symfony\Component\HttpKernel\HttpKernelInterface $app
-   *   The app.
-   */
-  public function __construct(HttpKernelInterface $app) {
-    $this->app = $app;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
-    $mapping = [
-      'application/json' => 'json',
-      'application/hal+json' => 'hal_json',
-      'application/xml' => 'xml',
-      'text/html' => 'html',
-    ];
-
-    $accept = $request->headers->get('Accept') ?: ['text/html'];
-    if (isset($mapping[$accept[0]])) {
-      $request->setRequestFormat($mapping[$accept[0]]);
-    }
-
-    return $this->app->handle($request, $type, $catch);
-  }
-
-}
diff --git a/core/modules/system/tests/modules/accept_header_routing_test/src/AcceptHeaderRoutingTestServiceProvider.php b/core/modules/system/tests/modules/accept_header_routing_test/src/AcceptHeaderRoutingTestServiceProvider.php
index e1cab64..98e30e9 100644
--- a/core/modules/system/tests/modules/accept_header_routing_test/src/AcceptHeaderRoutingTestServiceProvider.php
+++ b/core/modules/system/tests/modules/accept_header_routing_test/src/AcceptHeaderRoutingTestServiceProvider.php
@@ -21,8 +21,6 @@ class AcceptHeaderRoutingTestServiceProvider implements ServiceModifierInterface
   public function alter(ContainerBuilder $container) {
     // Remove the basic content negotation middleware and replace it with a
     // basic header based one.
-    $container->register('http_middleware.negotiation', 'Drupal\accept_header_routing_test\AcceptHeaderMiddleware')
-      ->addTag('http_middleware', ['priority' => 400]);
+    $container->register('http_negotiation.format_negotiator', 'Drupal\accept_header_routing_test\CustomContentNegotiation');
   }
-
 }
diff --git a/core/modules/system/tests/modules/accept_header_routing_test/src/CustomContentNegotiation.php b/core/modules/system/tests/modules/accept_header_routing_test/src/CustomContentNegotiation.php
new file mode 100644
index 0000000..ac72052
--- /dev/null
+++ b/core/modules/system/tests/modules/accept_header_routing_test/src/CustomContentNegotiation.php
@@ -0,0 +1,55 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\accept_header_routing_test\CustomContentNegotiation.
+ */
+
+namespace Drupal\accept_header_routing_test;
+
+use Drupal\Core\ContentNegotiationInterface;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * Provides content negotiation based upon query parameters and the accept header.
+ */
+class CustomContentNegotiation implements ContentNegotiationInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getContentType(Request $request) {
+    // AJAX iframe uploads need special handling, because they contain a JSON
+    // response wrapped in <textarea>.
+    if ($request->get('ajax_iframe_upload', FALSE)) {
+      return 'iframeupload';
+    }
+
+    if ($request->query->has('_format')) {
+      return $request->query->get('_format');
+    }
+
+    // Create accept header map.
+    $type_map = [
+      'application/json' => 'json',
+      'application/hal+json' => 'hal_json',
+      'application/xml' => 'xml',
+      'text/html' => 'html',
+    ];
+
+    // Get the first accept header.
+    $accept = explode(',', $request->headers->get('Accept'));
+
+    // Check to see if the accept header is in out list.
+    if (isset($type_map[$accept[0]])) {
+      return $type_map[$accept[0]];
+    }
+
+    if ($request->isXmlHttpRequest()) {
+      return 'ajax';
+    }
+
+    // Do HTML last so that it always wins.
+    return 'html';
+  }
+}
