Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ResponseHeaderBag #72

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

Merged
3 commits merged into from
Feb 22, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function set($key, $values, $replace = true)
parent::set($key, $values, $replace);

// ensure the cache-control header has sensible defaults
if ('cache-control' === strtr(strtolower($key), '_', '-')) {
if (in_array(strtr(strtolower($key), '_', '-'), array('cache-control', 'etag', 'last-modified', 'expires'))) {
$computed = $this->computeCacheControlValue();
$this->headers['cache-control'] = array($computed);
$this->computedCacheControl = $this->parseCacheControl($computed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,9 @@ public function testCacheControlHeader()

$bag = new ResponseHeaderBag(array('cache-control' => 'public, max-age=100'));
$this->assertEquals('max-age=100, public', $bag->get('Cache-Control'));

$bag = new ResponseHeaderBag();
$bag->set('Last-Modified', 'abcde');
$this->assertEquals('private, must-revalidate', $bag->get('Cache-Control'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public function testValidatesPrivateResponsesCachedOnTheClient()
$response->setContent('private data');
}
} else {
$response->headers->set('Cache-Control', 'public');
$response->setETag('"public tag"');
if (in_array('"public tag"', $etags)) {
$response->setStatusCode(304);
Expand Down Expand Up @@ -692,6 +693,7 @@ public function testReplacesCachedResponsesWhenValidationResultsInNon304Response
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time, &$count)
{
$response->headers->set('Last-Modified', $time->format(DATE_RFC2822));
$response->headers->set('Cache-Control', 'public');
switch (++$count) {
case 1:
$response->setContent('first response');
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.