Skip to content

Commit

Permalink
Work around 4GB file size limit at 32 Bit systems (#74)
Browse files Browse the repository at this point in the history
Closes #77
  • Loading branch information
derkostka authored and staabm committed Jun 12, 2017
1 parent 5f7bd40 commit 45c6e88
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/Sapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@ static function sendResponse(ResponseInterface $response) {
if ($contentLength !== null) {
$output = fopen('php://output', 'wb');
if (is_resource($body) && get_resource_type($body) == 'stream') {
stream_copy_to_stream($body, $output, (int)$contentLength);
if (PHP_INT_SIZE !== 4){
// use the dedicated function on 64 Bit systems
stream_copy_to_stream($body, $output, $contentLength);
} else {
// workaround for 32 Bit systems to avoid stream_copy_to_stream
while (!feof($body)) {
fwrite($output, fread($body, 8192));
}
}
} else {
fwrite($output, $body, (int)$contentLength);
}
Expand Down

0 comments on commit 45c6e88

Please sign in to comment.