diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php b/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php
index faebea4a..d6e418f6 100644
--- a/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php
+++ b/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php
@@ -68,18 +68,15 @@ public function testBlockLinks() {
     $href = $feed->toUrl()->toString();
     $links = $this->xpath('//a[@href = :href]', [':href' => $href]);
     $this->assert(isset($links[0]), new FormattableMarkup('Link to href %href found.', ['%href' => $href]));
-    $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
-    $cache_tags = explode(' ', $cache_tags_header);
-    $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
+    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'aggregator_feed:' . $feed->id());
 
     // Visit that page.
     $this->drupalGet($feed->toUrl()->getInternalPath());
     $correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', [':title' => $feed->label()]);
     $this->assertFalse(empty($correct_titles), 'Aggregator feed page is available and has the correct title.');
-    $cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
-    $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
-    $this->assertTrue(in_array('aggregator_feed_view', $cache_tags));
-    $this->assertTrue(in_array('aggregator_item_view', $cache_tags));
+    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'aggregator_feed:' . $feed->id());
+    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'aggregator_feed_view');
+    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'aggregator_item_view');
 
     // Set the number of news items to 0 to test that the block does not show
     // up.
@@ -120,9 +117,7 @@ public function testFeedPage() {
     $href = $feed->toUrl()->toString();
     $links = $this->xpath('//a[@href = :href]', [':href' => $href]);
     $this->assertTrue(isset($links[0]), new FormattableMarkup('Link to href %href found.', ['%href' => $href]));
-    $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
-    $cache_tags = explode(' ', $cache_tags_header);
-    $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
+    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'aggregator_feed:' . $feed->id());
 
     // Check the rss aggregator page as anonymous user.
     $this->drupalLogout();
@@ -133,7 +128,7 @@ public function testFeedPage() {
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('aggregator/rss');
     $this->assertResponse(200);
-    $this->assertEqual($this->drupalGetHeader('Content-type'), 'application/rss+xml; charset=utf-8');
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'application/rss+xml; charset=utf-8');
 
     // Check the opml aggregator page.
     $this->drupalGet('aggregator/opml');
@@ -150,10 +145,9 @@ public function testFeedPage() {
     $this->drupalGet('aggregator/sources/' . $feed->id());
     $elements = $this->xpath("//ul[contains(@class, :class)]", [':class' => 'pager__items']);
     $this->assertTrue(!empty($elements), 'Individual source page contains a pager.');
-    $cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
-    $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
-    $this->assertTrue(in_array('aggregator_feed_view', $cache_tags));
-    $this->assertTrue(in_array('aggregator_item_view', $cache_tags));
+    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'aggregator_feed:' . $feed->id());
+    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'aggregator_feed_view');
+    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'aggregator_item_view');
   }
 
 }
diff --git a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php
index b4485bb9..92e339cf 100644
--- a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php
+++ b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\basic_auth\Functional;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Url;
 use Drupal\Tests\basic_auth\Traits\BasicAuthTestTrait;
 use Drupal\language\Entity\ConfigurableLanguage;
@@ -46,7 +45,7 @@ public function testBasicAuth() {
     $this->assertText($account->getAccountName(), 'Account name is displayed.');
     $this->assertResponse('200', 'HTTP response is OK');
     $this->mink->resetSessions();
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
     // Check that Cache-Control is not set to public.
     $this->assertSession()->responseHeaderNotContains('Cache-Control', 'public');
 
@@ -56,7 +55,7 @@ public function testBasicAuth() {
     $this->mink->resetSessions();
 
     $this->drupalGet($url);
-    $this->assertEqual($this->drupalGetHeader('WWW-Authenticate'), new FormattableMarkup('Basic realm="@realm"', ['@realm' => \Drupal::config('system.site')->get('name')]));
+    $this->assertSession()->responseHeaderEquals('WWW-Authenticate', 'Basic realm="' . \Drupal::config('system.site')->get('name') . '"');
     $this->assertResponse('401', 'Not authenticated on the route that allows only basic_auth. Prompt to authenticate received.');
 
     $this->drupalGet('admin');
@@ -73,9 +72,9 @@ public function testBasicAuth() {
     // cache if basic auth credentials are provided.
     $url = Url::fromRoute('router_test.10');
     $this->drupalGet($url);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
     $this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw);
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
     // Check that Cache-Control is not set to public.
     $this->assertSession()->responseHeaderNotContains('Cache-Control', 'public');
   }
diff --git a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
index 83f82db8..b67cf222 100644
--- a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
+++ b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
@@ -258,7 +258,7 @@ public function testBigPipeNoJs() {
     ]);
 
     $this->pass('Verifying there are no BigPipe placeholders & replacements…', 'Debug');
-    $this->assertEqual('<none>', $this->drupalGetHeader('BigPipe-Test-Placeholders'));
+    $this->assertSession()->responseHeaderEquals('BigPipe-Test-Placeholders', '<none>');
     $this->pass('Verifying BigPipe start/stop signals are absent…', 'Debug');
     $this->assertNoRaw(BigPipe::START_SIGNAL, 'BigPipe start signal absent.');
     $this->assertNoRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal absent.');
@@ -323,8 +323,8 @@ protected function assertBigPipeResponseHeadersPresent() {
     $this->pass('Verifying BigPipe response headers…', 'Debug');
     // Check that Cache-Control header set to "private".
     $this->assertSession()->responseHeaderContains('Cache-Control', 'private');
-    $this->assertEqual('no-store, content="BigPipe/1.0"', $this->drupalGetHeader('Surrogate-Control'));
-    $this->assertEqual('no', $this->drupalGetHeader('X-Accel-Buffering'));
+    $this->assertSession()->responseHeaderEquals('Surrogate-Control', 'no-store, content="BigPipe/1.0"');
+    $this->assertSession()->responseHeaderEquals('X-Accel-Buffering', 'no');
   }
 
   /**
diff --git a/core/modules/block/tests/src/Functional/BlockTest.php b/core/modules/block/tests/src/Functional/BlockTest.php
index c6926345..d246dab4 100644
--- a/core/modules/block/tests/src/Functional/BlockTest.php
+++ b/core/modules/block/tests/src/Functional/BlockTest.php
@@ -377,12 +377,12 @@ public function testBlockCacheTags() {
 
     // Prime the page cache.
     $this->drupalGet('<front>');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
 
     // Verify a cache hit, but also the presence of the correct cache tags in
     // both the page and block caches.
     $this->drupalGet('<front>');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
     $cid_parts = [Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString(), ''];
     $cid = implode(':', $cid_parts);
     $cache_entry = \Drupal::cache('page')->get($cid);
@@ -410,20 +410,20 @@ public function testBlockCacheTags() {
     $block->setRegion('content');
     $block->save();
     $this->drupalGet('<front>');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
 
     // Now we should have a cache hit again.
     $this->drupalGet('<front>');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
 
     // Place the "Powered by Drupal" block another time; verify a cache miss.
     $this->drupalPlaceBlock('system_powered_by_block', ['id' => 'powered-2']);
     $this->drupalGet('<front>');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
 
     // Verify a cache hit, but also the presence of the correct cache tags.
     $this->drupalGet('<front>');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
     $cid_parts = [Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString(), ''];
     $cid = implode(':', $cid_parts);
     $cache_entry = \Drupal::cache('page')->get($cid);
@@ -459,14 +459,14 @@ public function testBlockCacheTags() {
 
     // Now we should have a cache hit again.
     $this->drupalGet('<front>');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
 
     // Delete the "Powered by Drupal" blocks; verify a cache miss.
     $block_storage = \Drupal::entityTypeManager()->getStorage('block');
     $block_storage->load('powered')->delete();
     $block_storage->load('powered-2')->delete();
     $this->drupalGet('<front>');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
   }
 
   /**
diff --git a/core/modules/config/tests/src/Functional/ConfigExportUITest.php b/core/modules/config/tests/src/Functional/ConfigExportUITest.php
index 46afdf64..5645fc32 100644
--- a/core/modules/config/tests/src/Functional/ConfigExportUITest.php
+++ b/core/modules/config/tests/src/Functional/ConfigExportUITest.php
@@ -58,9 +58,7 @@ public function testExport() {
     // Test if header contains file name with hostname and timestamp.
     $request = \Drupal::request();
     $hostname = str_replace('.', '-', $request->getHttpHost());
-    $header_content_disposition = $this->drupalGetHeader('content-disposition');
-    $header_match = (boolean) preg_match('/attachment; filename="config-' . preg_quote($hostname) . '-\d{4}-\d{2}-\d{2}-\d{2}-\d{2}\.tar\.gz"/', $header_content_disposition);
-    $this->assertTrue($header_match, "Header with filename matches the expected format.");
+    $this->assertSession()->responseHeaderMatches('content-disposition', '/attachment; filename="config-' . preg_quote($hostname) . '-\d{4}-\d{2}-\d{2}-\d{2}-\d{2}\.tar\.gz"/');
 
     // Extract the archive and verify it's not empty.
     $file_system = \Drupal::service('file_system');
diff --git a/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php b/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php
index 5d2ee654..5ff2651a 100644
--- a/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php
+++ b/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php
@@ -56,23 +56,23 @@ public function testDynamicPageCache() {
     // Cache.
     $url = Url::fromUri('route:dynamic_page_cache_test.response');
     $this->drupalGet($url);
-    $this->assertNull($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Response object returned: Dynamic Page Cache is ignoring.');
+    $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER));
 
     // Controllers returning CacheableResponseInterface (cacheable response)
     // objects are handled by Dynamic Page Cache.
     $url = Url::fromUri('route:dynamic_page_cache_test.cacheable_response');
     $this->drupalGet($url);
-    $this->assertEqual('MISS', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Cacheable response object returned: Dynamic Page Cache is active, Dynamic Page Cache MISS.');
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS');
     $this->drupalGet($url);
-    $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Cacheable response object returned: Dynamic Page Cache is active, Dynamic Page Cache HIT.');
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
 
     // Controllers returning render arrays, rendered as HTML responses, are
     // handled by Dynamic Page Cache.
     $url = Url::fromUri('route:dynamic_page_cache_test.html');
     $this->drupalGet($url);
-    $this->assertEqual('MISS', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as HTML response: Dynamic Page Cache is active, Dynamic Page Cache MISS.');
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS');
     $this->drupalGet($url);
-    $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as HTML response: Dynamic Page Cache is active, Dynamic Page Cache HIT.');
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
 
     // The above is the simple case, where the render array returned by the
     // response contains no cache contexts. So let's now test a route/controller
@@ -82,10 +82,10 @@ public function testDynamicPageCache() {
       $url = Url::fromUri('route:dynamic_page_cache_test.html.with_cache_contexts', ['query' => ['animal' => $animal]]);
       $this->drupalGet($url);
       $this->assertRaw($animal);
-      $this->assertEqual('MISS', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as HTML response: Dynamic Page Cache is active, Dynamic Page Cache MISS.');
+      $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS');
       $this->drupalGet($url);
       $this->assertRaw($animal);
-      $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as HTML response: Dynamic Page Cache is active, Dynamic Page Cache HIT.');
+      $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
 
       // Finally, let's also verify that the 'dynamic_page_cache_test.html'
       // route continued to see cache hits if we specify a query argument,
@@ -93,39 +93,39 @@ public function testDynamicPageCache() {
       // Cache hits.
       $url = Url::fromUri('route:dynamic_page_cache_test.html', ['query' => ['animal' => 'piglet']]);
       $this->drupalGet($url);
-      $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as HTML response: Dynamic Page Cache is active, Dynamic Page Cache HIT.');
+      $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
     }
 
     // Controllers returning render arrays, rendered as anything except a HTML
     // response, are ignored by Dynamic Page Cache (but only because those
     // wrapper formats' responses do not implement CacheableResponseInterface).
     $this->drupalGet('dynamic-page-cache-test/html', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
-    $this->assertNull($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as AJAX response: Dynamic Page Cache is ignoring.');
+    $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER));
     $this->drupalGet('dynamic-page-cache-test/html', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog']]);
-    $this->assertNull($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as dialog response: Dynamic Page Cache is ignoring.');
+    $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER));
     $this->drupalGet('dynamic-page-cache-test/html', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal']]);
-    $this->assertNull($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as modal response: Dynamic Page Cache is ignoring.');
+    $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER));
 
     // Admin routes are ignored by Dynamic Page Cache.
     $this->drupalGet('dynamic-page-cache-test/html/admin');
-    $this->assertNull($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Response returned, rendered as HTML response, admin route: Dynamic Page Cache is ignoring');
+    $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER));
     $this->drupalGet('dynamic-page-cache-test/response/admin');
-    $this->assertNull($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Response returned, plain response, admin route: Dynamic Page Cache is ignoring');
+    $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER));
     $this->drupalGet('dynamic-page-cache-test/cacheable-response/admin');
-    $this->assertNull($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Response returned, cacheable response, admin route: Dynamic Page Cache is ignoring');
+    $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER));
 
     // Max-age = 0 responses are ignored by Dynamic Page Cache.
     $this->drupalGet('dynamic-page-cache-test/html/uncacheable/max-age');
-    $this->assertEqual('UNCACHEABLE', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as HTML response, but uncacheable: Dynamic Page Cache is running, but not caching.');
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'UNCACHEABLE');
 
     // 'user' cache context responses are ignored by Dynamic Page Cache.
     $this->drupalGet('dynamic-page-cache-test/html/uncacheable/contexts');
-    $this->assertEqual('UNCACHEABLE', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as HTML response, but uncacheable: Dynamic Page Cache is running, but not caching.');
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'UNCACHEABLE');
 
     // 'current-temperature' cache tag responses are ignored by Dynamic Page
     // Cache.
     $this->drupalGet('dynamic-page-cache-test/html/uncacheable/tags');
-    $this->assertEqual('MISS', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'By default, Drupal has no auto-placeholdering cache tags.');
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS');
   }
 
 }
diff --git a/core/modules/file/tests/src/Functional/DownloadTest.php b/core/modules/file/tests/src/Functional/DownloadTest.php
index 21c867a3..4c6fed85 100644
--- a/core/modules/file/tests/src/Functional/DownloadTest.php
+++ b/core/modules/file/tests/src/Functional/DownloadTest.php
@@ -75,8 +75,8 @@ protected function doPrivateFileTransferTest() {
     file_test_reset();
     file_test_set_return('download', ['x-foo' => 'Bar']);
     $this->drupalGet($url);
-    $this->assertEqual($this->drupalGetHeader('x-foo'), 'Bar', 'Found header set by file_test module on private download.');
-    $this->assertNull($this->drupalGetHeader('x-drupal-cache'), 'Page cache is disabled on private file download.');
+    $this->assertSession()->responseHeaderEquals('x-foo', 'Bar');
+    $this->assertNull($this->getSession()->getResponseHeader('x-drupal-cache'));
     $this->assertResponse(200, 'Correctly allowed access to a file when file_test provides headers.');
     // Ensure hook_file_download is fired correctly.
     $this->assertEquals($file->getFileUri(), \Drupal::state()->get('file_test.results')['download'][0][0]);
diff --git a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php
index 9424eb25..94a5c2b6 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php
@@ -141,16 +141,15 @@ public function _testImageFieldFormatters($scheme) {
     $this->assertCacheTag($file->getCacheTags()[0]);
     // @todo Remove in https://www.drupal.org/node/2646744.
     $this->assertCacheContext('url.site');
-    $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
-    $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
+    $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:');
     $this->assertRaw($default_output, 'Image linked to file formatter displaying correctly on full node view.');
     // Verify that the image can be downloaded.
     $this->assertEqual(file_get_contents($test_image->uri), $this->drupalGet(file_create_url($image_uri)), 'File was downloaded successfully.');
     if ($scheme == 'private') {
       // Only verify HTTP headers when using private scheme and the headers are
       // sent by Drupal.
-      $this->assertEqual($this->drupalGetHeader('Content-Type'), 'image/png', 'Content-Type header was sent.');
-      $this->assertTrue(strstr($this->drupalGetHeader('Cache-Control'), 'private') !== FALSE, 'Cache-Control header was sent.');
+      $this->assertSession()->responseHeaderEquals('Content-Type', 'image/png');
+      $this->assertSession()->responseHeaderContains('Cache-Control', 'private');
 
       // Log out and try to access the file.
       $this->drupalLogout();
@@ -173,8 +172,7 @@ public function _testImageFieldFormatters($scheme) {
     ];
     $this->drupalGet('node/' . $nid);
     $this->assertCacheTag($file->getCacheTags()[0]);
-    $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
-    $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
+    $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:');
     $elements = $this->xpath(
       '//a[@href=:path]/img[@src=:url and @alt=:alt and @width=:width and @height=:height]',
       [
@@ -368,8 +366,7 @@ public function testImageFieldDefaultImage() {
     // Verify that no image is displayed on the page by checking for the class
     // that would be used on the image field.
     $this->assertSession()->responseNotMatches('<div class="(.*?)field--name-' . strtr($field_name, '_', '-') . '(.*?)">', 'No image displayed when no image is attached and no default image specified.');
-    $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
-    $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
+    $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:');
 
     // Add a default image to the public image field.
     $images = $this->drupalGetTestFiles('image');
@@ -399,8 +396,7 @@ public function testImageFieldDefaultImage() {
     $default_output = str_replace("\n", NULL, $renderer->renderRoot($image));
     $this->drupalGet('node/' . $node->id());
     $this->assertCacheTag($file->getCacheTags()[0]);
-    $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
-    $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
+    $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:');
     $this->assertRaw($default_output, 'Default image displayed when no user supplied image is present.');
 
     // Create a node with an image attached and ensure that the default image
@@ -424,8 +420,7 @@ public function testImageFieldDefaultImage() {
     $image_output = str_replace("\n", NULL, $renderer->renderRoot($image));
     $this->drupalGet('node/' . $nid);
     $this->assertCacheTag($file->getCacheTags()[0]);
-    $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
-    $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
+    $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:');
     $this->assertNoRaw($default_output, 'Default image is not displayed when user supplied image is present.');
     $this->assertRaw($image_output, 'User supplied image is displayed.');
 
@@ -475,8 +470,7 @@ public function testImageFieldDefaultImage() {
     $default_output = str_replace("\n", NULL, $renderer->renderRoot($image));
     $this->drupalGet('node/' . $node->id());
     $this->assertCacheTag($file->getCacheTags()[0]);
-    $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
-    $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
+    $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:');
     $this->assertRaw($default_output, 'Default private image displayed when no user supplied image is present.');
   }
 
diff --git a/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php b/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php
index a5e35368..69e12b40 100644
--- a/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php
+++ b/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php
@@ -207,19 +207,19 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s
     // assertRaw can't be used with string containing non UTF-8 chars.
     $this->assertNotEmpty(file_get_contents($generated_uri), 'URL returns expected file.');
     $image = $this->container->get('image.factory')->get($generated_uri);
-    $this->assertEqual($this->drupalGetHeader('Content-Type'), $image->getMimeType(), 'Expected Content-Type was reported.');
-    $this->assertEqual($this->drupalGetHeader('Content-Length'), $image->getFileSize(), 'Expected Content-Length was reported.');
+    $this->assertSession()->responseHeaderEquals('Content-Type', $image->getMimeType());
+    $this->assertSession()->responseHeaderEquals('Content-Length', (string) $image->getFileSize());
 
     // Check that we did not download the original file.
     $original_image = $this->container->get('image.factory')
       ->get($original_uri);
-    $this->assertNotEqual($this->drupalGetHeader('Content-Length'), $original_image->getFileSize());
+    $this->assertSession()->responseHeaderNotEquals('Content-Length', (string) $original_image->getFileSize());
 
     if ($scheme == 'private') {
-      $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.');
+      $this->assertSession()->responseHeaderEquals('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT');
       // Check that Cache-Control header contains 'no-cache' to prevent caching.
       $this->assertSession()->responseHeaderContains('Cache-Control', 'no-cache');
-      $this->assertEqual($this->drupalGetHeader('X-Image-Owned-By'), 'image_module_test', 'Expected custom header has been added.');
+      $this->assertSession()->responseHeaderEquals('X-Image-Owned-By', 'image_module_test');
 
       // Make sure that a second request to the already existing derivative
       // works too.
@@ -227,10 +227,10 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s
       $this->assertResponse(200, 'Image was generated at the URL.');
 
       // Check that the second request also returned the generated image.
-      $this->assertEqual($this->drupalGetHeader('Content-Length'), $image->getFileSize());
+      $this->assertSession()->responseHeaderEquals('Content-Length', (string) $image->getFileSize());
 
       // Check that we did not download the original file.
-      $this->assertNotEqual($this->drupalGetHeader('Content-Length'), $original_image->getFileSize());
+      $this->assertSession()->responseHeaderNotEquals('Content-Length', (string) $original_image->getFileSize());
 
       // Make sure that access is denied for existing style files if we do not
       // have access.
@@ -262,8 +262,8 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s
       }
     }
     else {
-      $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.');
-      $this->assertStringNotContainsString('no-cache', $this->drupalGetHeader('Cache-Control'), 'Cache-Control header contains \'no-cache\' to prevent caching.');
+      $this->assertSession()->responseHeaderEquals('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT');
+      $this->assertSession()->responseHeaderNotContains('Cache-Control', 'no-cache');
 
       if ($clean_url) {
         // Add some extra chars to the token.
diff --git a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php
index 06d76892..57237615 100644
--- a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php
@@ -79,32 +79,32 @@ public function testAcceptLanguageEmptyDefault() {
 
     $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => 'en']);
     $this->assertSession()->responseHeaderEquals('Content-Language', 'en');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
 
     // Check with UK browser.
     $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => 'en-UK,en']);
     $this->assertSession()->responseHeaderEquals('Content-Language', 'en');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
 
     // Check with french browser.
     $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => 'fr-FR,fr']);
     $this->assertSession()->responseHeaderEquals('Content-Language', 'fr');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
 
     // Check with browser without language settings - should return fallback language.
     $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => NULL]);
     $this->assertSession()->responseHeaderEquals('Content-Language', 'en');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
 
     // Check with french browser again.
     $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => 'fr-FR,fr']);
     $this->assertSession()->responseHeaderEquals('Content-Language', 'fr');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
 
     // Check with UK browser.
     $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => 'en-UK,en']);
     $this->assertSession()->responseHeaderEquals('Content-Language', 'en');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
 
     // Check if prefixed URLs are still cached.
     $this->drupalGet('/en/system-test/echo/language test', [], ['Accept-Language' => 'en']);
diff --git a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php
index 6c3cbb70..c4f2f505 100644
--- a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php
+++ b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\layout_builder\Functional;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Url;
 use Drupal\Tests\BrowserTestBase;
 use Drupal\Tests\field\Traits\EntityReferenceTestTrait;
@@ -128,8 +127,7 @@ public function testEntityReferenceFieldBlockCaching() {
    */
   protected function verifyPageCacheContainsTags(Url $url, $hit_or_miss, $tags = FALSE) {
     $this->drupalGet($url);
-    $message = new FormattableMarkup('Page cache @hit_or_miss for %path.', ['@hit_or_miss' => $hit_or_miss, '%path' => $url->toString()]);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), $hit_or_miss, $message);
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', $hit_or_miss);
 
     if ($hit_or_miss === 'HIT' && is_array($tags)) {
       $cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
diff --git a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php
index b607560a..4d30d843 100644
--- a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php
+++ b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php
@@ -60,11 +60,11 @@ public function testPageCacheTags() {
     $path = 'system-test/cache_tags_page';
     $tags = ['system_test_cache_tags_page'];
     $this->drupalGet($path);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
 
     // Verify a cache hit, but also the presence of the correct cache tags.
     $this->drupalGet($path);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
     $cid_parts = [Url::fromRoute('system_test.cache_tags_page', [], ['absolute' => TRUE])->toString(), ''];
     $cid = implode(':', $cid_parts);
     $cache_entry = \Drupal::cache('page')->get($cid);
@@ -80,7 +80,7 @@ public function testPageCacheTags() {
 
     Cache::invalidateTags($tags);
     $this->drupalGet($path);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
   }
 
   /**
@@ -95,11 +95,11 @@ public function testPageCacheTagsIndependentFromCacheabilityHeaders() {
     $path = 'system-test/cache_tags_page';
     $tags = ['system_test_cache_tags_page'];
     $this->drupalGet($path);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
 
     // Verify a cache hit, but also the presence of the correct cache tags.
     $this->drupalGet($path);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
     $cid_parts = [Url::fromRoute('system_test.cache_tags_page', [], ['absolute' => TRUE])->toString(), ''];
     $cid = implode(':', $cid_parts);
     $cache_entry = \Drupal::cache('page')->get($cid);
@@ -115,7 +115,7 @@ public function testPageCacheTagsIndependentFromCacheabilityHeaders() {
 
     Cache::invalidateTags($tags);
     $this->drupalGet($path);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
   }
 
   /**
@@ -131,15 +131,15 @@ public function testQueryParameterFormatRequests() {
     $accept_header_cache_url_with_json = Url::fromRoute('system_test.page_cache_accept_header', ['_format' => 'json']);
 
     $this->drupalGet($accept_header_cache_url);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'HTML page was not yet cached.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
     $this->drupalGet($accept_header_cache_url);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'HTML page was cached.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
     $this->assertRaw('<p>oh hai this is html.</p>', 'The correct HTML response was returned.');
 
     $this->drupalGet($accept_header_cache_url_with_json);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Json response was not yet cached.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
     $this->drupalGet($accept_header_cache_url_with_json);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Json response was cached.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
     $this->assertRaw('{"content":"oh hai this is json"}', 'The correct Json response was returned.');
 
     // Enable REST support for nodes and hal+json.
@@ -150,37 +150,37 @@ public function testQueryParameterFormatRequests() {
     $node_url_with_hal_json_format = $node->toUrl('canonical')->setRouteParameter('_format', 'hal_json');
 
     $this->drupalGet($node_uri);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
-    $this->assertEqual($this->drupalGetHeader('Content-Type'), 'text/html; charset=UTF-8');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'text/html; charset=UTF-8');
     $this->drupalGet($node_uri);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
-    $this->assertEqual($this->drupalGetHeader('Content-Type'), 'text/html; charset=UTF-8');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'text/html; charset=UTF-8');
 
     // Now request a HAL page, we expect that the first request is a cache miss
     // and it serves HTML.
     $this->drupalGet($node_url_with_hal_json_format);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
-    $this->assertEqual($this->drupalGetHeader('Content-Type'), 'application/hal+json');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'application/hal+json');
     $this->drupalGet($node_url_with_hal_json_format);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
-    $this->assertEqual($this->drupalGetHeader('Content-Type'), 'application/hal+json');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'application/hal+json');
 
     // Clear the page cache. After that request a HAL request, followed by an
     // ordinary HTML one.
     \Drupal::cache('page')->deleteAll();
     $this->drupalGet($node_url_with_hal_json_format);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
-    $this->assertEqual($this->drupalGetHeader('Content-Type'), 'application/hal+json');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'application/hal+json');
     $this->drupalGet($node_url_with_hal_json_format);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
-    $this->assertEqual($this->drupalGetHeader('Content-Type'), 'application/hal+json');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'application/hal+json');
 
     $this->drupalGet($node_uri);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
-    $this->assertEqual($this->drupalGetHeader('Content-Type'), 'text/html; charset=UTF-8');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'text/html; charset=UTF-8');
     $this->drupalGet($node_uri);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
-    $this->assertEqual($this->drupalGetHeader('Content-Type'), 'text/html; charset=UTF-8');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'text/html; charset=UTF-8');
   }
 
   /**
@@ -197,7 +197,7 @@ public function testConditionalRequests() {
     $this->assertSession()->responseNotMatches('#<html.*<html#');
 
     $this->drupalGet('');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
     $etag = $this->drupalGetHeader('ETag');
     $last_modified = $this->drupalGetHeader('Last-Modified');
 
@@ -220,20 +220,20 @@ public function testConditionalRequests() {
     // Verify the page is not printed twice when the cache is warm.
     $this->assertSession()->responseNotMatches('#<html.*<html#');
     $this->assertResponse(200, 'Conditional request without If-None-Match returned 200 OK.');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
 
     $this->drupalGet('', [], [
       'If-Modified-Since' => gmdate(DateTimePlus::RFC7231, strtotime($last_modified) + 1),
       'If-None-Match' => $etag,
     ]);
     $this->assertResponse(200, 'Conditional request with new a If-Modified-Since date newer than Last-Modified returned 200 OK.');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
 
     $user = $this->drupalCreateUser();
     $this->drupalLogin($user);
     $this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => $etag]);
     $this->assertResponse(200, 'Conditional request returned 200 OK for authenticated user.');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'), 'Absence of Page was not cached.');
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
   }
 
   /**
@@ -246,44 +246,44 @@ public function testPageCache() {
 
     // Fill the cache.
     $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'bar']]);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
-    $this->assertContains('cookie', explode(',', strtolower($this->drupalGetHeader('Vary'))), 'Vary header was sent.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
+    $this->assertSession()->responseHeaderContains('Vary', 'cookie');
     // Symfony's Response logic determines a specific order for the subvalues
     // of the Cache-Control header, even if they are explicitly passed in to
     // the response header bag in a different order.
-    $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=300, public', 'Cache-Control header was sent.');
-    $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.');
-    $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.');
+    $this->assertSession()->responseHeaderEquals('Cache-Control', 'max-age=300, public');
+    $this->assertSession()->responseHeaderEquals('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT');
+    $this->assertSession()->responseHeaderEquals('Foo', 'bar');
 
     // Check cache.
     $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'bar']]);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
-    $this->assertContains('cookie', explode(',', strtolower($this->drupalGetHeader('Vary'))), 'Vary header was sent.');
-    $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=300, public', 'Cache-Control header was sent.');
-    $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.');
-    $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
+    $this->assertSession()->responseHeaderContains('Vary', 'cookie');
+    $this->assertSession()->responseHeaderEquals('Cache-Control', 'max-age=300, public');
+    $this->assertSession()->responseHeaderEquals('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT');
+    $this->assertSession()->responseHeaderEquals('Foo', 'bar');
 
     // Check replacing default headers.
     $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Expires', 'value' => 'Fri, 19 Nov 2008 05:00:00 GMT']]);
-    $this->assertEqual($this->drupalGetHeader('Expires'), 'Fri, 19 Nov 2008 05:00:00 GMT', 'Default header was replaced.');
+    $this->assertSession()->responseHeaderEquals('Expires', 'Fri, 19 Nov 2008 05:00:00 GMT');
     $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Vary', 'value' => 'User-Agent']]);
-    $this->assertContains('user-agent', explode(',', strtolower($this->drupalGetHeader('Vary'))), 'Default header was replaced.');
+    $this->assertSession()->responseHeaderContains('Vary', 'user-agent');
 
     // Check that authenticated users bypass the cache.
     $user = $this->drupalCreateUser();
     $this->drupalLogin($user);
     $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'bar']]);
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'), 'Caching was bypassed.');
-    $this->assertStringNotContainsStringIgnoringCase('cookie', $this->drupalGetHeader('Vary'), 'Vary: Cookie header was not sent.');
-    $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'must-revalidate, no-cache, private', 'Cache-Control header was sent.');
-    $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.');
-    $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.');
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
+    $this->assertSession()->responseHeaderNotContains('Vary', 'cookie');
+    $this->assertSession()->responseHeaderEquals('Cache-Control', 'must-revalidate, no-cache, private');
+    $this->assertSession()->responseHeaderEquals('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT');
+    $this->assertSession()->responseHeaderEquals('Foo', 'bar');
 
     // Until bubbling of max-age up to the response is supported, verify that
     // a custom #cache max-age set on an element does not affect page max-age.
     $this->drupalLogout();
     $this->drupalGet('system-test/cache_maxage_page');
-    $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=300, public');
+    $this->assertSession()->responseHeaderEquals('Cache-Control', 'max-age=300, public');
   }
 
   /**
@@ -363,11 +363,11 @@ public function testPageCacheAnonymous403404() {
       // Anonymous user, without permissions.
       $this->drupalGet($content_url);
       $this->assertResponse($code);
-      $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+      $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
       $this->assertCacheTag('4xx-response');
       $this->drupalGet($content_url);
       $this->assertResponse($code);
-      $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
+      $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
       $entity_values = [
         'name' => $this->randomMachineName(),
         'user_id' => 1,
@@ -383,15 +383,15 @@ public function testPageCacheAnonymous403404() {
       // Saving an entity clears 4xx cache tag.
       $this->drupalGet($content_url);
       $this->assertResponse($code);
-      $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+      $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
       $this->drupalGet($content_url);
       $this->assertResponse($code);
-      $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
+      $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
       // Rebuilding the router should invalidate the 4xx cache tag.
       $this->container->get('router.builder')->rebuild();
       $this->drupalGet($content_url);
       $this->assertResponse($code);
-      $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+      $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
 
       // Ensure the 'expire' field on the cache entry uses cache_ttl_4xx.
       $cache_item = \Drupal::service('cache.page')->get($this->getUrl() . ':');
@@ -420,7 +420,7 @@ public function testPageCacheAnonymous403404() {
       $this->drupalGet($content_url);
       $this->drupalGet($content_url);
       $this->assertResponse($code);
-      $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+      $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
     }
   }
 
@@ -440,15 +440,15 @@ public function testPageCacheWithoutVaryCookie() {
 
     // Fill the cache.
     $this->drupalGet('');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
-    $this->assertStringNotContainsStringIgnoringCase('cookie', $this->drupalGetHeader('Vary'), 'Vary: Cookie header was not sent.');
-    $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=300, public', 'Cache-Control header was sent.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
+    $this->assertSession()->responseHeaderNotContains('Vary', 'cookie');
+    $this->assertSession()->responseHeaderEquals('Cache-Control', 'max-age=300, public');
 
     // Check cache.
     $this->drupalGet('');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
-    $this->assertStringNotContainsStringIgnoringCase('cookie', $this->drupalGetHeader('Vary'), 'Vary: Cookie header was not sent.');
-    $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=300, public', 'Cache-Control header was sent.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
+    $this->assertSession()->responseHeaderNotContains('Vary', 'cookie');
+    $this->assertSession()->responseHeaderEquals('Cache-Control', 'max-age=300, public');
   }
 
   /**
@@ -493,33 +493,33 @@ public function testCacheableResponseResponses() {
 
     // GET a URL, which would be marked as a cache miss if it were cacheable.
     $this->drupalGet('/system-test/respond-reponse');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'), 'Drupal page cache header not found.');
-    $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'must-revalidate, no-cache, private', 'Cache-Control header was sent');
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
+    $this->assertSession()->responseHeaderEquals('Cache-Control', 'must-revalidate, no-cache, private');
 
     // GET it again, verify it's still not cached.
     $this->drupalGet('/system-test/respond-reponse');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'), 'Drupal page cache header not found.');
-    $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'must-revalidate, no-cache, private', 'Cache-Control header was sent');
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
+    $this->assertSession()->responseHeaderEquals('Cache-Control', 'must-revalidate, no-cache, private');
 
     // GET a URL, which would be marked as a cache miss if it were cacheable.
     $this->drupalGet('/system-test/respond-public-response');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'), 'Drupal page cache header not found.');
-    $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=60, public', 'Cache-Control header was sent');
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
+    $this->assertSession()->responseHeaderEquals('Cache-Control', 'max-age=60, public');
 
     // GET it again, verify it's still not cached.
     $this->drupalGet('/system-test/respond-public-response');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'), 'Drupal page cache header not found.');
-    $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=60, public', 'Cache-Control header was sent');
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
+    $this->assertSession()->responseHeaderEquals('Cache-Control', 'max-age=60, public');
 
     // GET a URL, which should be marked as a cache miss.
     $this->drupalGet('/system-test/respond-cacheable-reponse');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
-    $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=300, public', 'Cache-Control header was sent.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
+    $this->assertSession()->responseHeaderEquals('Cache-Control', 'max-age=300, public');
 
     // GET it again, it should now be a cache hit.
     $this->drupalGet('/system-test/respond-cacheable-reponse');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
-    $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=300, public', 'Cache-Control header was sent.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
+    $this->assertSession()->responseHeaderEquals('Cache-Control', 'max-age=300, public');
 
     // Uninstall page cache. This should flush all caches so the next call to a
     // previously cached page should be a miss now.
@@ -528,7 +528,7 @@ public function testCacheableResponseResponses() {
 
     // GET a URL that was cached by Page Cache before, it should not be now.
     $this->drupalGet('/respond-cacheable-reponse');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'), 'Drupal page cache header not found.');
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
   }
 
   /**
@@ -541,8 +541,8 @@ public function testHead() {
     // GET, then HEAD.
     $url_a = $this->buildUrl('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'bar']]);
     $response_body = $this->drupalGet($url_a);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
-    $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
+    $this->assertSession()->responseHeaderEquals('Foo', 'bar');
     $this->assertEqual('The following header was set: <em class="placeholder">Foo</em>: <em class="placeholder">bar</em>', $response_body);
     $response = $client->request('HEAD', $url_a);
     $this->assertEqual($response->getHeaderLine('X-Drupal-Cache'), 'HIT', 'Page was cached.');
@@ -552,12 +552,12 @@ public function testHead() {
     // HEAD, then GET.
     $url_b = $this->buildUrl('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'baz']]);
     $response = $client->request('HEAD', $url_b);
-    $this->assertEqual($response->getHeaderLine('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
-    $this->assertEqual($response->getHeaderLine('Foo'), 'baz', 'Custom header was sent.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
+    $this->assertSession()->responseHeaderEquals('Foo', 'baz');
     $this->assertEqual('', $response->getBody()->getContents());
     $response_body = $this->drupalGet($url_b);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
-    $this->assertEqual($this->drupalGetHeader('Foo'), 'baz', 'Custom header was sent.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
+    $this->assertSession()->responseHeaderEquals('Foo', 'baz');
     $this->assertEqual('The following header was set: <em class="placeholder">Foo</em>: <em class="placeholder">baz</em>', $response_body);
   }
 
diff --git a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php
index a7a11461..8b518a1f 100644
--- a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php
+++ b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php
@@ -252,8 +252,8 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
       ->save();
 
     $this->drupalGet('node/' . $nid);
-    $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
-    $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
+    // No image style cache tag should be found.
+    $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:');
 
     $this->assertPattern('/<a(.*?)href="' . preg_quote(file_url_transform_relative(file_create_url($image_uri)), '/') . '"(.*?)>\s*<picture/');
     // Verify that the image can be downloaded.
@@ -261,8 +261,8 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
     if ($scheme == 'private') {
       // Only verify HTTP headers when using private scheme and the headers are
       // sent by Drupal.
-      $this->assertEqual($this->drupalGetHeader('Content-Type'), 'image/png', 'Content-Type header was sent.');
-      $this->assertTrue(strstr($this->drupalGetHeader('Cache-Control'), 'private') !== FALSE, 'Cache-Control header was sent.');
+      $this->assertSession()->responseHeaderEquals('Content-Type', 'image/png');
+      $this->assertSession()->responseHeaderContains('Cache-Control', 'private');
 
       // Log out and try to access the file.
       $this->drupalLogout();
@@ -307,14 +307,13 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
       $this->assertRaw('media="(min-width: 851px)"');
     }
     $this->assertRaw('/styles/large/');
-    $cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
-    $this->assertTrue(in_array('config:responsive_image.styles.style_one', $cache_tags));
+    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:responsive_image.styles.style_one');
     if (!$empty_styles) {
-      $this->assertTrue(in_array('config:image.style.medium', $cache_tags));
-      $this->assertTrue(in_array('config:image.style.thumbnail', $cache_tags));
+      $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:image.style.medium');
+      $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:image.style.thumbnail');
       $this->assertRaw('type="image/png"');
     }
-    $this->assertTrue(in_array('config:image.style.large', $cache_tags));
+    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:image.style.large');
 
     // Test the fallback image style.
     $image = \Drupal::service('image.factory')->get($image_uri);
@@ -334,8 +333,7 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
       $this->drupalLogout();
       $this->drupalGet($large_style->buildUrl($image_uri));
       $this->assertResponse('403', 'Access denied to image style large as anonymous user.');
-      $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
-      $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
+      $this->assertSession()->responseHeaderNotMatches('X-Drupal-Cache-Tags', '/ image_style\:/');
     }
   }
 
diff --git a/core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php b/core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php
index 6b4d3a95..506eaceb 100644
--- a/core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php
+++ b/core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php
@@ -79,7 +79,7 @@ protected function assertPageCacheContextsAndTags(Url $url, array $expected_cont
 
     // Assert cache miss + expected cache contexts + tags.
     $this->drupalGet($absolute_url);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
     $this->assertCacheTags($expected_tags);
     $this->assertCacheContexts($expected_contexts);
 
@@ -156,8 +156,7 @@ protected function assertCacheContexts(array $expected_contexts, $message = NULL
    * @param int $max_age
    */
   protected function assertCacheMaxAge($max_age) {
-    $cache_control_header = $this->drupalGetHeader('Cache-Control');
-    $this->assertStringContainsString('max-age:' . $max_age, $cache_control_header);
+    $this->assertSession()->responseHeaderContains('Cache-Control', 'max-age:' . $max_age);
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Cache/PageCacheTagsTestBase.php b/core/modules/system/tests/src/Functional/Cache/PageCacheTagsTestBase.php
index 5398e218..a6625812 100644
--- a/core/modules/system/tests/src/Functional/Cache/PageCacheTagsTestBase.php
+++ b/core/modules/system/tests/src/Functional/Cache/PageCacheTagsTestBase.php
@@ -43,8 +43,7 @@ protected function setUp() {
    */
   protected function verifyPageCache(Url $url, $hit_or_miss, $tags = FALSE) {
     $this->drupalGet($url);
-    $message = new FormattableMarkup('Page cache @hit_or_miss for %path.', ['@hit_or_miss' => $hit_or_miss, '%path' => $url->toString()]);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), $hit_or_miss, $message);
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', $hit_or_miss);
 
     if ($hit_or_miss === 'HIT' && is_array($tags)) {
       $absolute_url = $url->setAbsolute()->toString();
diff --git a/core/modules/system/tests/src/Functional/Common/RenderWebTest.php b/core/modules/system/tests/src/Functional/Common/RenderWebTest.php
index 5ac988f1..6376fa92 100644
--- a/core/modules/system/tests/src/Functional/Common/RenderWebTest.php
+++ b/core/modules/system/tests/src/Functional/Common/RenderWebTest.php
@@ -34,12 +34,12 @@ class RenderWebTest extends BrowserTestBase {
   public function testWrapperFormatCacheContext() {
     $this->drupalGet('common-test/type-link-active-class');
     $this->assertStringStartsWith("<!DOCTYPE html>\n<html", $this->getSession()->getPage()->getContent());
-    $this->assertIdentical('text/html; charset=UTF-8', $this->drupalGetHeader('Content-Type'));
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'text/html; charset=UTF-8');
     $this->assertTitle('Test active link class | Drupal');
     $this->assertCacheContext('url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT);
 
     $this->drupalGet('common-test/type-link-active-class', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'json']]);
-    $this->assertIdentical('application/json', $this->drupalGetHeader('Content-Type'));
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'application/json');
     $json = Json::decode($this->getSession()->getPage()->getContent());
     $this->assertEqual(['content', 'title'], array_keys($json));
     $this->assertIdentical('Test active link class', $json['title']);
diff --git a/core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php b/core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php
index abfe8467..dbed3047 100644
--- a/core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php
+++ b/core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php
@@ -46,7 +46,7 @@ protected function getFormBuildId() {
    */
   public function testValidateFormStorageOnCachedPage() {
     $this->drupalGet('form-test/form-storage-page-cache');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
     $this->assertText('No old build id', 'No old build id on the page');
     $build_id_initial = $this->getFormBuildId();
 
@@ -66,7 +66,7 @@ public function testValidateFormStorageOnCachedPage() {
 
     // Repeat the test sequence but this time with a page loaded from the cache.
     $this->drupalGet('form-test/form-storage-page-cache');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
     $this->assertText('No old build id', 'No old build id on the page');
     $build_id_from_cache_initial = $this->getFormBuildId();
     $this->assertEqual($build_id_initial, $build_id_from_cache_initial, 'Build id is the same as on the first request');
@@ -92,7 +92,7 @@ public function testValidateFormStorageOnCachedPage() {
    */
   public function testRebuildFormStorageOnCachedPage() {
     $this->drupalGet('form-test/form-storage-page-cache');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
     $this->assertText('No old build id', 'No old build id on the page');
     $build_id_initial = $this->getFormBuildId();
 
diff --git a/core/modules/system/tests/src/Functional/Form/ResponseTest.php b/core/modules/system/tests/src/Functional/Form/ResponseTest.php
index bbeac92c..58ec48f2 100644
--- a/core/modules/system/tests/src/Functional/Form/ResponseTest.php
+++ b/core/modules/system/tests/src/Functional/Form/ResponseTest.php
@@ -36,8 +36,8 @@ public function testFormResponse() {
     $content = Json::decode($this->getSession()->getPage()->getContent());
     $this->assertResponse(200);
     $this->assertIdentical($edit['content'], $content, 'Response content matches');
-    $this->assertIdentical('invoked', $this->drupalGetHeader('X-Form-Test-Response-Event'), 'Response handled by kernel response subscriber');
-    $this->assertIdentical('invoked', $this->drupalGetHeader('X-Form-Test-Stack-Middleware'), 'Response handled by kernel middleware');
+    $this->assertSession()->responseHeaderEquals('X-Form-Test-Response-Event', 'invoked');
+    $this->assertSession()->responseHeaderEquals('X-Form-Test-Stack-Middleware', 'invoked');
 
     $edit = [
       'content' => $this->randomString(),
@@ -47,8 +47,8 @@ public function testFormResponse() {
     $content = Json::decode($this->getSession()->getPage()->getContent());
     $this->assertResponse(418);
     $this->assertIdentical($edit['content'], $content, 'Response content matches');
-    $this->assertIdentical('invoked', $this->drupalGetHeader('X-Form-Test-Response-Event'), 'Response handled by kernel response subscriber');
-    $this->assertIdentical('invoked', $this->drupalGetHeader('X-Form-Test-Stack-Middleware'), 'Response handled by kernel middleware');
+    $this->assertSession()->responseHeaderEquals('X-Form-Test-Response-Event', 'invoked');
+    $this->assertSession()->responseHeaderEquals('X-Form-Test-Stack-Middleware', 'invoked');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Menu/LocalActionTest.php b/core/modules/system/tests/src/Functional/Menu/LocalActionTest.php
index b4a7375b..eb9a9ace 100644
--- a/core/modules/system/tests/src/Functional/Menu/LocalActionTest.php
+++ b/core/modules/system/tests/src/Functional/Menu/LocalActionTest.php
@@ -54,8 +54,7 @@ public function testLocalAction() {
       [Url::fromRoute('menu_test.local_action5'), 'Original title'],
     ]);
     // Verify the expected cache tag in the response headers.
-    $header_values = explode(' ', $this->drupalGetHeader('x-drupal-cache-tags'));
-    $this->assertTrue(in_array('config:menu_test.links.action', $header_values), "Found 'config:menu_test.links.action' cache tag in header");
+    $this->assertSession()->responseHeaderContains('x-drupal-cache-tags', 'config:menu_test.links.action');
     /** @var \Drupal\Core\Config\Config $config */
     $config = $this->container->get('config.factory')->getEditable('menu_test.links.action');
     $config->set('title', 'New title');
diff --git a/core/modules/system/tests/src/Functional/Routing/RouterTest.php b/core/modules/system/tests/src/Functional/Routing/RouterTest.php
index a162f188..b0ae69f7 100644
--- a/core/modules/system/tests/src/Functional/Routing/RouterTest.php
+++ b/core/modules/system/tests/src/Functional/Routing/RouterTest.php
@@ -46,7 +46,7 @@ public function testFinishResponseSubscriber() {
     $this->assertEquals($headers['Content-language'], ['en']);
     $this->assertEquals($headers['X-Content-Type-Options'], ['nosniff']);
     $this->assertEquals($headers['X-Frame-Options'], ['SAMEORIGIN']);
-    $this->assertNull($this->drupalGetHeader('Vary'), 'Vary header is not set.');
+    $this->assertNull($this->getSession()->getResponseHeader('Vary'));
 
     $this->drupalGet('router_test/test2');
     $this->assertRaw('test2', 'The correct string was returned because the route was successful.');
@@ -291,7 +291,7 @@ public function testControllerResolutionAjax() {
     $headers[] = 'X-Requested-With: XMLHttpRequest';
     $this->drupalGet('/router_test/test10', $options, $headers);
 
-    $this->assertEqual($this->drupalGetHeader('Content-Type'), 'application/json', 'Correct mime content type was returned');
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'application/json');
 
     $this->assertRaw('abcde', 'Correct body was found.');
   }
diff --git a/core/modules/system/tests/src/Functional/Session/SessionTest.php b/core/modules/system/tests/src/Functional/Session/SessionTest.php
index 37ffe4cc..2bc43cce 100644
--- a/core/modules/system/tests/src/Functional/Session/SessionTest.php
+++ b/core/modules/system/tests/src/Functional/Session/SessionTest.php
@@ -51,7 +51,7 @@ public function testSessionSaveRegenerate() {
     // Start a new session by setting a message.
     $this->drupalGet('session-test/set-message');
     $this->assertSessionCookie(TRUE);
-    $this->assertRegExp('/HttpOnly/i', $this->drupalGetHeader('Set-Cookie', TRUE), 'Session cookie is set as HttpOnly.');
+    $this->assertSession()->responseHeaderMatches('Set-Cookie', '/HttpOnly/i');
 
     // Verify that the session is regenerated if a module calls exit
     // in hook_user_login().
@@ -187,21 +187,21 @@ public function testEmptyAnonymousSession() {
     $this->assertSessionCookie(FALSE);
     // @todo Reinstate when REQUEST and RESPONSE events fire for cached pages.
     // $this->assertSessionEmpty(TRUE);
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
 
     // Start a new session by setting a message.
     $this->drupalGet('session-test/set-message');
     $this->assertSessionCookie(TRUE);
-    $this->assertNotEmpty($this->drupalGetHeader('Set-Cookie'), 'New session was started.');
+    $this->assertNotNull($this->getSession()->getResponseHeader('Set-Cookie'));
 
     // Display the message, during the same request the session is destroyed
     // and the session cookie is unset.
     $this->drupalGet('');
     $this->assertSessionCookie(FALSE);
     $this->assertSessionEmpty(FALSE);
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'), 'Caching was bypassed.');
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
     $this->assertText(t('This is a dummy message.'), 'Message was displayed.');
-    $this->assertRegExp('/SESS\w+=deleted/', $this->drupalGetHeader('Set-Cookie'), 'Session cookie was deleted.');
+    $this->assertSession()->responseHeaderMatches('Set-Cookie', '/SESS\w+=deleted/');
 
     // Verify that session was destroyed.
     $this->drupalGet('');
@@ -209,8 +209,8 @@ public function testEmptyAnonymousSession() {
     // @todo Reinstate when REQUEST and RESPONSE events fire for cached pages.
     // $this->assertSessionEmpty(TRUE);
     $this->assertNoText(t('This is a dummy message.'), 'Message was not cached.');
-    $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
-    $this->assertNull($this->drupalGetHeader('Set-Cookie'), 'New session was not started.');
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
+    $this->assertNull($this->getSession()->getResponseHeader('Set-Cookie'));
 
     // Verify that no session is created if drupal_save_session(FALSE) is called.
     $this->drupalGet('session-test/set-message-but-dont-save');
@@ -355,10 +355,10 @@ public function assertSessionCookie($sent) {
    */
   public function assertSessionEmpty($empty) {
     if ($empty) {
-      $this->assertIdentical($this->drupalGetHeader('X-Session-Empty'), '1', 'Session was empty.');
+      $this->assertSession()->responseHeaderEquals('X-Session-Empty', '1');
     }
     else {
-      $this->assertIdentical($this->drupalGetHeader('X-Session-Empty'), '0', 'Session was not empty.');
+      $this->assertSession()->responseHeaderEquals('X-Session-Empty', '0');
     }
   }
 
diff --git a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php
index c2775b8e..76fe6d58 100644
--- a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php
+++ b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php
@@ -141,7 +141,7 @@ public function testExceptionHandler() {
       ->save();
 
     $this->drupalGet('error-test/trigger-exception');
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
     $this->assertSession()->responseHeaderNotContains('Cache-Control', 'public');
     $this->assertSession()->statusCodeEquals(500);
     $this->assertNoErrorMessage($error_exception);
diff --git a/core/modules/system/tests/src/Functional/System/HtaccessTest.php b/core/modules/system/tests/src/Functional/System/HtaccessTest.php
index 074b3c00..0b1089d0 100644
--- a/core/modules/system/tests/src/Functional/System/HtaccessTest.php
+++ b/core/modules/system/tests/src/Functional/System/HtaccessTest.php
@@ -155,8 +155,7 @@ public function testSvgzContentEncoding() {
 
     // Use x-encoded-content-encoding because of Content-Encoding responses
     // (gzip, deflate, etc.) are automatically decoded by Guzzle.
-    $header = $this->drupalGetHeader('x-encoded-content-encoding');
-    $this->assertEqual($header, 'gzip');
+    $this->assertSession()->responseHeaderEquals('x-encoded-content-encoding', 'gzip');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/System/ResponseGeneratorTest.php b/core/modules/system/tests/src/Functional/System/ResponseGeneratorTest.php
index 3d44528b..87c7cb9f 100644
--- a/core/modules/system/tests/src/Functional/System/ResponseGeneratorTest.php
+++ b/core/modules/system/tests/src/Functional/System/ResponseGeneratorTest.php
@@ -48,14 +48,14 @@ public function testGeneratorHeaderAdded() {
     // Check to see if the header is added when viewing a normal content page
     $this->drupalGet($node->toUrl());
     $this->assertResponse(200);
-    $this->assertEqual('text/html; charset=UTF-8', $this->drupalGetHeader('Content-Type'));
-    $this->assertEqual($expectedGeneratorHeader, $this->drupalGetHeader('X-Generator'));
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'text/html; charset=UTF-8');
+    $this->assertSession()->responseHeaderEquals('X-Generator', $expectedGeneratorHeader);
 
     // Check to see if the header is also added for a non-successful response
     $this->drupalGet('llama');
     $this->assertResponse(404);
-    $this->assertEqual('text/html; charset=UTF-8', $this->drupalGetHeader('Content-Type'));
-    $this->assertEqual($expectedGeneratorHeader, $this->drupalGetHeader('X-Generator'));
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'text/html; charset=UTF-8');
+    $this->assertSession()->responseHeaderEquals('X-Generator', $expectedGeneratorHeader);
 
     // Enable cookie-based authentication for the entity:node REST resource.
     /** @var \Drupal\rest\RestResourceConfigInterface $resource_config */
@@ -68,8 +68,8 @@ public function testGeneratorHeaderAdded() {
     // Tests to see if this also works for a non-html request
     $this->drupalGet($node->toUrl()->setOption('query', ['_format' => 'hal_json']));
     $this->assertResponse(200);
-    $this->assertEqual('application/hal+json', $this->drupalGetHeader('Content-Type'));
-    $this->assertEqual($expectedGeneratorHeader, $this->drupalGetHeader('X-Generator'));
+    $this->assertSession()->responseHeaderEquals('Content-Type', 'application/hal+json');
+    $this->assertSession()->responseHeaderEquals('X-Generator', $expectedGeneratorHeader);
 
   }
 
diff --git a/core/modules/user/tests/src/Functional/UserBlocksTest.php b/core/modules/user/tests/src/Functional/UserBlocksTest.php
index 0030612d..2b228a43 100644
--- a/core/modules/user/tests/src/Functional/UserBlocksTest.php
+++ b/core/modules/user/tests/src/Functional/UserBlocksTest.php
@@ -85,7 +85,7 @@ public function testUserLoginBlock() {
     // Now, log out and repeat with a non-403 page.
     $this->drupalLogout();
     $this->drupalGet('filter/tips');
-    $this->assertEqual('MISS', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER));
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS');
     $this->drupalPostForm(NULL, $edit, t('Log in'));
     $this->assertNoText(t('User login'), 'Logged in.');
     $this->assertPattern('!<title.*?' . t('Compose tips') . '.*?</title>!', 'Still on the same page after login for allowed page');
@@ -93,7 +93,7 @@ public function testUserLoginBlock() {
     // Log out again and repeat with a non-403 page including query arguments.
     $this->drupalLogout();
     $this->drupalGet('filter/tips', ['query' => ['foo' => 'bar']]);
-    $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER));
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
     $this->drupalPostForm(NULL, $edit, t('Log in'));
     $this->assertNoText(t('User login'), 'Logged in.');
     $this->assertPattern('!<title.*?' . t('Compose tips') . '.*?</title>!', 'Still on the same page after login for allowed page');
@@ -102,7 +102,7 @@ public function testUserLoginBlock() {
     // Repeat with different query arguments.
     $this->drupalLogout();
     $this->drupalGet('filter/tips', ['query' => ['foo' => 'baz']]);
-    $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER));
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
     $this->drupalPostForm(NULL, $edit, t('Log in'));
     $this->assertNoText(t('User login'), 'Logged in.');
     $this->assertPattern('!<title.*?' . t('Compose tips') . '.*?</title>!', 'Still on the same page after login for allowed page');
diff --git a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php
index e59194f5..6a542a38 100644
--- a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php
+++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php
@@ -92,11 +92,11 @@ public function testUserPasswordReset() {
     // Ensure that the current url does not contain the hash and timestamp.
     $this->assertUrl(Url::fromRoute('user.reset.form', ['uid' => $this->account->id()]));
 
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
 
     // Ensure the password reset URL is not cached.
     $this->drupalGet($resetURL);
-    $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache'));
 
     // Check the one-time login page.
     $this->assertText($this->account->getAccountName(), 'One-time login page contains the correct username.');
diff --git a/core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php b/core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php
index 77f43eb5..ec85a3ea 100644
--- a/core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php
@@ -245,9 +245,9 @@ public function testTableCacheability() {
     $url = 'test-table';
     $this->drupalGet($url);
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertEquals('MISS', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER));
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS');
     $this->drupalGet($url);
-    $this->assertEquals('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER));
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
   }
 
 }
diff --git a/core/profiles/standard/tests/src/Functional/StandardTest.php b/core/profiles/standard/tests/src/Functional/StandardTest.php
index 1f7c111e..b2f0d03d 100644
--- a/core/profiles/standard/tests/src/Functional/StandardTest.php
+++ b/core/profiles/standard/tests/src/Functional/StandardTest.php
@@ -188,22 +188,22 @@ public function testStandard() {
     $this->drupalLogin($this->adminUser);
     $url = Url::fromRoute('contact.site_page');
     $this->drupalGet($url);
-    $this->assertEqual('UNCACHEABLE', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Site-wide contact page cannot be cached by Dynamic Page Cache.');
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'UNCACHEABLE');
 
     $url = Url::fromRoute('<front>');
     $this->drupalGet($url);
     $this->drupalGet($url);
-    $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Frontpage is cached by Dynamic Page Cache.');
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
 
     $url = Url::fromRoute('entity.node.canonical', ['node' => 1]);
     $this->drupalGet($url);
     $this->drupalGet($url);
-    $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Full node page is cached by Dynamic Page Cache.');
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
 
     $url = Url::fromRoute('entity.user.canonical', ['user' => 1]);
     $this->drupalGet($url);
     $this->drupalGet($url);
-    $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'User profile page is cached by Dynamic Page Cache.');
+    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
 
     // Make sure the editorial workflow is installed after enabling the
     // content_moderation module.
diff --git a/core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php b/core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php
index c0f3d884..8693d110 100644
--- a/core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php
+++ b/core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php
@@ -22,17 +22,17 @@ class DefaultFormatTest extends BrowserTestBase {
   public function testFoo() {
     $this->drupalGet('/default_format_test/human');
     $this->assertSame('format:html', $this->getSession()->getPage()->getContent());
-    $this->assertSame('MISS', $this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
     $this->drupalGet('/default_format_test/human');
     $this->assertSame('format:html', $this->getSession()->getPage()->getContent());
-    $this->assertSame('HIT', $this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
 
     $this->drupalGet('/default_format_test/machine');
     $this->assertSame('format:json', $this->getSession()->getPage()->getContent());
-    $this->assertSame('MISS', $this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
     $this->drupalGet('/default_format_test/machine');
     $this->assertSame('format:json', $this->getSession()->getPage()->getContent());
-    $this->assertSame('HIT', $this->drupalGetHeader('X-Drupal-Cache'));
+    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
   }
 
   public function testMultipleRoutesWithSameSingleFormat() {
