8000 [HttpFoundation] Do not append "private" to "no-cache" in the Cache-Control header by jakzal · Pull Request #17181 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] Do not append "private" to "no-cache" in the Cache-Control header #17181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[HttpFoundation] Do not append "private" to "no-cache" in the Cache-C…
…ontrol header
  • Loading branch information
jakzal committed Dec 30, 2015
commit bea740a15fc2b0a919a923877b102ccca718673c
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ protected function computeCacheControlValue()
}

$header = $this->getCacheControlHeader();
if (isset($this->cacheControl['public']) || isset($this->cacheControl['private'])) {
if (isset($this->cacheControl['public']) || isset($this->cacheControl['private']) || isset($this->cacheControl['no-cache'])) {
return $header;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public function provideAllPreserveCase()
array('fOo' => 'BAR'),
array('fOo' => array('BAR'), 'Cache-Control' => array('no-cache')),
),
array(
array('fOo' => 'BAR', 'Cache-Control' => array('no-cache')),
array('fOo' => array('BAR'), 'Cache-Control' => array('no-cache')),
),
array(
array('ETag' => 'xyzzy'),
array('ETag' => array('xyzzy'), 'Cache-Control' => array('private, must-revalidate')),
Expand Down Expand Up @@ -63,6 +67,14 @@ public function provideAllPreserveCase()
);
}

public function testHeadersArePreserved()
{
$bag1 = new ResponseHeaderBag(array('test'));
$bag2 = new ResponseHeaderBag($bag1->allPreserveCase());

$this->assertEquals($bag1->allPreserveCase(), $bag2->allPreserveCase());
}

public function testCacheControlHeader()
{
$bag = new ResponseHeaderBag(array());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testPrepareWith11Protocol()

$this->assertEquals('1.1', $response->getProtocolVersion());
$this->assertNotEquals('chunked', $response->headers->get('Transfer-Encoding'), 'Apache assumes responses with a Transfer-Encoding header set to chunked to already be encoded.');
$this->assertEquals('no-cache, private', $response->headers->get('Cache-Control'));
$this->assertEquals('no-cache', $response->headers->get('Cache-Control'));
}

public function testPrepareWith10Protocol()
Expand All @@ -47,7 +47,7 @@ public function testPrepareWith10Protocol()

$this->assertEquals('1.0', $response->getProtocolVersion());
$this->assertNull($response->headers->get('Transfer-Encoding'));
$this->assertEquals('no-cache, private', $response->headers->get('Cache-Control'));
$this->assertEquals('no-cache', $response->headers->get('Cache-Control'));
}

public function testPrepareWithHeadRequest()
Expand Down
0