diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index a5c77f0ab7446..61af1e4d99457 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -22,6 +22,7 @@ * @author Igor Wiedler * @author Jordan Alliot * @author Sergey Linnik + * @author Povilas Skruibis */ class BinaryFileResponse extends Response { @@ -123,11 +124,23 @@ public function setAutoLastModified() */ public function setAutoEtag() { - $this->setEtag(sha1_file($this->file->getPathname())); + $this->setEtag($this->calculateFileHash($this->file->getPathname())); return $this; } + /** + * Calculate file hash + * + * @param string $filename The path to the file + * + * @return string + */ + protected function calculateFileHash($filename) + { + return sha1_file($filename); + } + /** * Sets the Content-Disposition header with the given filename. *