Skip to content

[HttpCache] bug: response body is served with 304 status code #1413

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

Closed
ghost opened this issue Jun 23, 2011 · 0 comments · Fixed by #1414
Closed

[HttpCache] bug: response body is served with 304 status code #1413

ghost opened this issue Jun 23, 2011 · 0 comments · Fixed by #1414

Comments

@ghost
Copy link

ghost commented Jun 23, 2011

This bug occurs when AppCache is used and the response is pulled from cache.

Serving response body with 304 status code is against HTTP spec.

This bug can be fixed here:

diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
index 705e762..78960a2 100644
--- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
+++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
@@ -550,7 +550,7 @@ class HttpCache implements HttpKernelInterface
      */
     private function restoreResponseBody(Request $request, Response $response)
     {
-        if ('head' === strtolower($request->getMethod())) {
+        if ('head' === strtolower($request->getMethod()) || 304 == $response->getStatusCode()) {
             $response->setContent('');
             $response->headers->remove('X-Body-Eval');
             $response->headers->remove('X-Body-File');

but the solution will need some unit testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant