Skip to content

Commit 3fcd053

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Console] Application update PHPDoc of add and register methods [Config] Extra tests for Config component Fixed bugs in names of classes and methods. [DoctrineBridge] Fixed php doc [FrameworkBundle] Fixed parameters number mismatch declaration [BrowserKit] Added test for followRedirect method (POST method) Fix the money form type render with Bootstrap3 [BrowserKit] Uppercase the "GET" method in redirects [WebProfilerBundle] Fixed JSDoc parameter definition [HttpFoundation] HttpCache refresh stale responses containing an ETag Conflicts: src/Symfony/Component/BrowserKit/Tests/ClientTest.php src/Symfony/Component/Security/Acl/Resources/bin/generateSql.php
2 parents 37c7be0 + 26e15ae commit 3fcd053

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

HttpCache/HttpCache.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@ protected function lock(Request $request, Response $entry)
600600
*/
601601
protected function store(Request $request, Response $response)
602602
{
603+
if (!$response->headers->has('Date')) {
604+
$response->setDate(\DateTime::createFromFormat('U', time()));
605+
}
603606
try {
604607
$this->store->write($request, $response);
605608

Tests/HttpCache/HttpCacheTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,31 @@ public function testRespondsWith304OnlyIfIfNoneMatchAndIfModifiedSinceBothMatch(
181181
$this->assertEquals(304, $this->response->getStatusCode());
182182
}
183183

184+
public function testIncrementsMaxAgeWhenNoDateIsSpecifiedEventWhenUsingETag()
185+
{
186+
$this->setNextResponse(
187+
200,
188+
array(
189+
'ETag' => '1234',
190+
'Cache-Control' => 'public, s-maxage=60',
191+
)
192+
);
193+
194+
$this->request('GET', '/');
195+
$this->assertHttpKernelIsCalled();
196+
$this->assertEquals(200, $this->response->getStatusCode());
197+
$this->assertTraceContains('miss');
198+
$this->assertTraceContains('store');
199+
200+
sleep(2);
201+
202+
$this->request('GET', '/');
203+
$this->assertHttpKernelIsNotCalled();
204+
$this->assertEquals(200, $this->response->getStatusCode());
205+
$this->assertTraceContains('fresh');
206+
$this->assertEquals(2, $this->response->headers->get('Age'));
207+
}
208+
184209
public function testValidatesPrivateResponsesCachedOnTheClient()
185210
{
186211
$this->setNextResponse(200, array(), '', function ($request, $response) {

0 commit comments

Comments
 (0)