Skip to content

Navigation Menu

Sign in
Appearance settings

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

Commit 66afa01

Browse filesBrowse files
committed
[HttpFoundation] added private by default when setting Cache-Control to no-cache
1 parent 1298ce5 commit 66afa01
Copy full SHA for 66afa01

File tree

Expand file treeCollapse file tree

5 files changed

+30
-13
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+30
-13
lines changed

‎src/Symfony/Component/HttpFoundation/Response.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Response.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public function prepare(Request $request)
307307
}
308308

309309
// Check if we need to send extra expire info headers
310-
if ('1.0' == $this->getProtocolVersion() && 'no-cache' == $this->headers->get('Cache-Control')) {
310+
if ('1.0' == $this->getProtocolVersion() && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) {
311311
$this->headers->set('pragma', 'no-cache');
312312
$this->headers->set('expires', -1);
313313
}

‎src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public function makeDisposition($disposition, $filename, $filenameFallback = '')
281281
protected function computeCacheControlValue()
282282
{
283283
if (!$this->cacheControl && !$this->has('ETag') && !$this->has('Last-Modified') && !$this->has('Expires')) {
284-
return 'no-cache';
284+
return 'no-cache, private';
285285
}
286286

287287
if (!$this->cacheControl) {

‎src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,15 @@ public function testCacheControlDirectiveOverrideWithReplace()
171171
$this->assertEquals(10, $bag->getCacheControlDirective('max-age'));
172172
}
173173

174+
public function testCacheControlClone()
175+
{
176+
$headers = array('foo' => 'bar');
177+
$bag1 = new HeaderBag($headers);
178+
$bag2 = new HeaderBag($bag1->all());
179+
180+
$this->assertEquals($bag1->all(), $bag2->all());
181+
}
182+
174183
public function testGetIterator()
175184
{
176185
$headers = array('foo' => 'bar', 'hello' => 'world', 'third' => 'charm');

‎src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php
+18-10Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,39 @@ public function provideAllPreserveCase()
3434
return array(
3535
array(
3636
array('fOo' => 'BAR'),
37-
array('fOo' => array('BAR'), 'Cache-Control' => array('no-cache')),
37+
array('fOo' => array('BAR'), 'Cache-Control' => array('no-cache, private')),
3838
),
3939
array(
4040
array('ETag' => 'xyzzy'),
4141
array('ETag' => array('xyzzy'), 'Cache-Control' => array('private, must-revalidate')),
4242
),
4343
array(
4444
array('Content-MD5' => 'Q2hlY2sgSW50ZWdyaXR5IQ=='),
45-
array('Content-MD5' => array('Q2hlY2sgSW50ZWdyaXR5IQ=='), 'Cache-Control' => array('no-cache')),
45+
array('Content-MD5' => array('Q2hlY2sgSW50ZWdyaXR5IQ=='), 'Cache-Control' => array('no-cache, private')),
4646
),
4747
array(
4848
array('P3P' => 'CP="CAO PSA OUR"'),
49-
array('P3P' => array('CP="CAO PSA OUR"'), 'Cache-Control' => array('no-cache')),
49+
array('P3P' => array('CP="CAO PSA OUR"'), 'Cache-Control' => array('no-cache, private')),
5050
),
5151
array(
5252
array('WWW-Authenticate' => 'Basic realm="WallyWorld"'),
53-
array('WWW-Authenticate' => array('Basic realm="WallyWorld"'), 'Cache-Control' => array('no-cache')),
53+
array('WWW-Authenticate' => array('Basic realm="WallyWorld"'), 'Cache-Control' => array('no-cache, private')),
5454
),
5555
array(
5656
array('X-UA-Compatible' => 'IE=edge,chrome=1'),
57-
array('X-UA-Compatible' => array('IE=edge,chrome=1'), 'Cache-Control' => array('no-cache')),
57+
array('X-UA-Compatible' => array('IE=edge,chrome=1'), 'Cache-Control' => array('no-cache, private')),
5858
),
5959
array(
6060
array('X-XSS-Protection' => '1; mode=block'),
61-
array('X-XSS-Protection' => array('1; mode=block'), 'Cache-Control' => array('no-cache')),
61+
array('X-XSS-Protection' => array('1; mode=block'), 'Cache-Control' => array('no-cache, private')),
6262
),
6363
);
6464
}
6565

6666
public function testCacheControlHeader()
6767
{
6868
$bag = new ResponseHeaderBag(array());
69-
$this->assertEquals('no-cache', $bag->get('Cache-Control'));
69+
$this->assertEquals('no-cache, private', $bag->get('Cache-Control'));
7070
$this->assertTrue($bag->hasCacheControlDirective('no-cache'));
7171

7272
$bag = new ResponseHeaderBag(array('Cache-Control' => 'public'));
@@ -111,6 +111,14 @@ public function testCacheControlHeader()
111111
$this->assertEquals('private, must-revalidate', $bag->get('Cache-Control'));
112112
}
113113

114+
public function testCacheControlClone()
115+
{
116+
$headers = array('foo' => 'bar');
117+
$bag1 = new ResponseHeaderBag($headers);
118+
$bag2 = new ResponseHeaderBag($bag1->allPreserveCase());
119+
$this->assertEquals($bag1->allPreserveCase(), $bag2->allPreserveCase());
120+
}
121+
114122
public function testToStringIncludesCookieHeaders()
115123
{
116124
$bag = new ResponseHeaderBag(array());
@@ -135,7 +143,7 @@ public function testClearCookieSecureNotHttpOnly()
135143
public function testReplace()
136144
{
137145
$bag = new ResponseHeaderBag(array());
138-
$this->assertEquals('no-cache', $bag->get('Cache-Control'));
146+
$this->assertEquals('no-cache, private', $bag->get('Cache-Control'));
139147
$this->assertTrue($bag->hasCacheControlDirective('no-cache'));
140148

141149
$bag->replace(array('Cache-Control' => 'public'));
@@ -146,12 +154,12 @@ public function testReplace()
146154
public function testReplaceWithRemove()
147155
{
148156
$bag = new ResponseHeaderBag(array());
149-
$this->assertEquals('no-cache', $bag->get('Cache-Control'));
157+
$this->assertEquals('no-cache, private', $bag->get('Cache-Control'));
150158
$this->assertTrue($bag->hasCacheControlDirective('no-cache'));
151159

152160
$bag->remove('Cache-Control');
153161
$bag->replace(array());
154-
$this->assertEquals('no-cache', $bag->get('Cache-Control'));
162+
$this->assertEquals('no-cache, private', $bag->get('Cache-Control'));
155163
$this->assertTrue($bag->hasCacheControlDirective('no-cache'));
156164
}
157165

‎src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testToString()
3333
$response = new Response();
3434
$response = explode("\r\n", $response);
3535
$this->assertEquals('HTTP/1.0 200 OK', $response[0]);
36-
$this->assertEquals('Cache-Control: no-cache', $response[1]);
36+
$this->assertEquals('Cache-Control: no-cache, private', $response[1]);
3737
}
3838

3939
public function testClone()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.