diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index f794d94e29d45..dcbce22b8916f 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -374,7 +374,9 @@ protected function validate(Request $request, Response $entry, $catch = false) $subRequest = clone $request; // send no head requests because we want content - $subRequest->setMethod('GET'); + if ('HEAD' === $request->getMethod()) { + $subRequest->setMethod('GET'); + } // add our cached last-modified validator $subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified')); @@ -435,7 +437,9 @@ protected function fetch(Request $request, $catch = false) $subRequest = clone $request; // send no head requests because we want content - $subRequest->setMethod('GET'); + if ('HEAD' === $request->getMethod()) { + $subRequest->setMethod('GET'); + } // avoid that the backend sends no content $subRequest->headers->remove('if_modified_since'); diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index b6164dd6782fb..497f6fbde72aa 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -774,6 +774,21 @@ public function testValidatesCachedResponsesWithLastModifiedAndNoFreshnessInform $this->assertTraceNotContains('miss'); } + public function testValidatesCachedResponsesUseSameHttpMethod() + { + $test = $this; + + $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($test) { + $test->assertSame('OPTIONS', $request->getMethod()); + }); + + // build initial request + $this->request('OPTIONS', '/'); + + // build subsequent request + $this->request('OPTIONS', '/'); + } + public function testValidatesCachedResponsesWithETagAndNoFreshnessInformation() { $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy