From 059b6800b51065aa5df1cb99fa87094868eb7c90 Mon Sep 17 00:00:00 2001 From: Sebastian Kostka Date: Sun, 11 Jun 2017 22:25:21 +0200 Subject: [PATCH] Create Sapi.php --- lib/Sapi.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Sapi.php b/lib/Sapi.php index 4101f82..534a8f0 100644 --- a/lib/Sapi.php +++ b/lib/Sapi.php @@ -88,8 +88,14 @@ static function sendResponse(ResponseInterface $response) { if ($contentLength !== null) { $output = fopen('php://output', 'wb'); if (is_resource($body) && get_resource_type($body) == 'stream') { - while (!feof($body)) { - fwrite($output,fread($body,8192)); + 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);