瀏覽代碼

[HttpKernel] fixed empty ETags showing up in requests to the backend when using HttpCache

Fabien Potencier 14 年之前
父節點
當前提交
1f0ffca68e
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php

+ 4 - 3
src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php

@@ -325,10 +325,11 @@ class HttpCache implements HttpKernelInterface
         // Add our cached etag validator to the environment.
         // We keep the etags from the client to handle the case when the client
         // has a different private valid entry which is not cached here.
-        $cachedEtags = array($entry->getEtag());
+        $cachedEtags = $entry->getEtag() ? array($entry->getEtag()) : array();
         $requestEtags = $request->getEtags();
-        $etags = array_unique(array_merge($cachedEtags, $requestEtags));
-        $subRequest->headers->set('if_none_match', $etags ? implode(', ', $etags) : '');
+        if ($etags = array_unique(array_merge($cachedEtags, $requestEtags))) {
+            $subRequest->headers->set('if_none_match', implode(', ', $etags));
+        }
 
         $response = $this->forward($subRequest, $catch, $entry);