Skip to content

Commit

Permalink
moved file hash calculation to own method
Browse files Browse the repository at this point in the history
  • Loading branch information
povilas authored and fabpot committed Feb 11, 2013
1 parent c5fcf0d commit a923849
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Symfony/Component/HttpFoundation/BinaryFileResponse.php
Expand Up @@ -22,6 +22,7 @@
* @author Igor Wiedler <igor@wiedler.ch>
* @author Jordan Alliot <jordan.alliot@gmail.com>
* @author Sergey Linnik <linniksa@gmail.com>
* @author Povilas Skruibis <puovils@gmail.com>
*/
class BinaryFileResponse extends Response
{
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit a923849

Please sign in to comment.