function AssetOptimizationTest::assertGzip

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php \Drupal\FunctionalTests\Asset\AssetOptimizationTest::assertGzip()

Tests gzip compression.

Parameters

string $url: The source URL.

File

core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php, line 202

Class

AssetOptimizationTest
Tests asset aggregation.

Namespace

Drupal\FunctionalTests\Asset

Code

protected function assertGzip(string $url) : void {
  $this->getSession()
    ->setRequestHeader('Accept-Encoding', 'gzip');
  $this->getSession()
    ->visit($url);
  $this->assertSession()
    ->statusCodeEquals(200);
  // Guzzle decodes the gzip response automatically but adds the original
  // Content-Encoding value in this header.
  $this->assertSession()
    ->responseHeaderEquals('x-encoded-content-encoding', 'gzip');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.