function ContentLengthTest::testContentLength

Same name in other branches
  1. 11.x core/tests/Drupal/FunctionalTests/HttpKernel/ContentLengthTest.php \Drupal\FunctionalTests\HttpKernel\ContentLengthTest::testContentLength()

File

core/tests/Drupal/FunctionalTests/HttpKernel/ContentLengthTest.php, line 27

Class

ContentLengthTest
Tests Content-Length set by Drupal.

Namespace

Drupal\FunctionalTests\HttpKernel

Code

public function testContentLength() : void {
    // Fire off a request.
    $this->drupalGet(Url::fromRoute('http_middleware_test.test_response'));
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->responseHeaderEquals('Content-Length', '40');
    $this->setContainerParameter('no-alter-content-length', TRUE);
    $this->rebuildContainer();
    // Fire the same exact request but this time length is different.
    $this->drupalGet(Url::fromRoute('http_middleware_test.test_response'));
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->responseHeaderEquals('Content-Length', '41');
}

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