Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around file size issues at 32 Bit systems #74

Merged
merged 5 commits into from
Jun 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, 8192 seems low. I think you should push blocks 1MB at a time. It's not the 80's anymore ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as this path is used for 32bit php its a bit like php from the 80's :-)

}
}
} else {
fwrite($output, $body, (int)$contentLength);
}
Expand Down