Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c043117

Browse files
committed
[HttpFoundation] Fixed BinaryFileResponse sending wrong Content-Length header for files modified by stream wrappers/filters.
1 parent 2d08be1 commit c043117

File tree

1 file changed

+14
-0
lines changed
  • src/Symfony/Component/HttpFoundation/File

1 file changed

+14
-0
lines changed

src/Symfony/Component/HttpFoundation/File/File.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,18 @@ protected function getName($name)
133133

134134
return $originalName;
135135
}
136+
137+
/**
138+
* {@inheritdoc}
139+
*/
140+
public function getSize()
141+
{
142+
// Since stream wrappers and stream filters can change the file contents as read, the only
143+
// reliable way to get the effective size of the file is to actually read it.
144+
ob_start();
145+
$size = readfile($this->getPathname());
146+
ob_end_clean();
147+
148+
return $size;
149+
}
136150
}

0 commit comments

Comments
 (0)