// Check replacing default headers.
$this->
drupalGet('system-test/set-header',
['query' =>
['name' => 'Expires', 'value' => 'Fri, 19 Nov 2008 05:00:00 GMT'
]]);
$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->
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->
assertSession()->
responseHeaderDoesNotExist('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->
assertSession()->
responseHeaderEquals('Cache-Control', 'max-age=300, public'
);
}