Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitfa063a1

Browse files
committed
bug#43998 [HttpKernel] [HttpCache] Don't throw on 304 Not Modified (aleho)
This PR was merged into the 4.4 branch.Discussion----------[HttpKernel] [HttpCache] Don't throw on 304 Not Modified| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fixes#43997| License | MIT| Doc PR | ~If the response cache keeps a `Last-Modified` header clients will request with `If-Modified-Since`.The surrogate will not handle a `304 Not Modified` correctly, resulting in a 500 and a failed request.This fixes that request / response cycle, as observed in testing PR#42355.Commits-------d27f02a [HttpKernel] [HttpCache] Don't throw on 304 Not Modified
2 parents180eade +d27f02a commitfa063a1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

‎src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors)
9595
try {
9696
$response =$cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST,true);
9797

98-
if (!$response->isSuccessful()) {
98+
if (!$response->isSuccessful() && Response::HTTP_NOT_MODIFIED !==$response->getStatusCode()) {
9999
thrownew \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).',$subRequest->getUri(),$response->getStatusCode()));
100100
}
101101

‎src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,15 @@ public function testHandleWhenResponseIsNot200AndAltIsPresent()
221221
$this->assertEquals('bar',$esi->handle($cache,'/','/alt',false));
222222
}
223223

224+
publicfunctiontestHandleWhenResponseIsNotModified()
225+
{
226+
$esi =newEsi();
227+
$response =newResponse('');
228+
$response->setStatusCode(304);
229+
$cache =$this->getCache(Request::create('/'),$response);
230+
$this->assertEquals('',$esi->handle($cache,'/','/alt',true));
231+
}
232+
224233
protectedfunctiongetCache($request,$response)
225234
{
226235
$cache =$this->getMockBuilder(HttpCache::class)->setMethods(['getRequest','handle'])->disableOriginalConstructor()->getMock();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp