From 108a3efe0b6d37a7ed394a84c69b924ca727f17a Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 11 Oct 2022 18:34:03 +0000 Subject: update composer libs --- vendor/sabre/http/lib/Sapi.php | 62 ++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 35 deletions(-) (limited to 'vendor/sabre/http/lib/Sapi.php') diff --git a/vendor/sabre/http/lib/Sapi.php b/vendor/sabre/http/lib/Sapi.php index 823d5df25..f8e8397fc 100644 --- a/vendor/sabre/http/lib/Sapi.php +++ b/vendor/sabre/http/lib/Sapi.php @@ -26,7 +26,7 @@ use InvalidArgumentException; * * php://output * * You can choose to either call all these methods statically, but you can also - * instantiate this as an object to allow for polymorhpism. + * instantiate this as an object to allow for polymorphism. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) @@ -89,41 +89,33 @@ class Sapi if (null !== $contentLength) { $output = fopen('php://output', 'wb'); if (is_resource($body) && 'stream' == get_resource_type($body)) { - if (PHP_INT_SIZE > 4) { - // use the dedicated function on 64 Bit systems - // a workaround to make PHP more possible to use mmap based copy, see https://github.com/sabre-io/http/pull/119 - $left = (int) $contentLength; - // copy with 4MiB chunks - $chunk_size = 4 * 1024 * 1024; - stream_set_chunk_size($output, $chunk_size); - // If this is a partial response, flush the beginning bytes until the first position that is a multiple of the page size. - $contentRange = $response->getHeader('Content-Range'); - // Matching "Content-Range: bytes 1234-5678/7890" - if (null !== $contentRange && preg_match('/^bytes\s([0-9]+)-([0-9]+)\//i', $contentRange, $matches)) { - // 4kB should be the default page size on most architectures - $pageSize = 4096; - $offset = (int) $matches[1]; - $delta = ($offset % $pageSize) > 0 ? ($pageSize - $offset % $pageSize) : 0; - if ($delta > 0) { - $left -= stream_copy_to_stream($body, $output, min($delta, $left)); - } + // a workaround to make PHP more possible to use mmap based copy, see https://github.com/sabre-io/http/pull/119 + $left = (int) $contentLength; + // copy with 4MiB chunks + $chunk_size = 4 * 1024 * 1024; + stream_set_chunk_size($output, $chunk_size); + // If this is a partial response, flush the beginning bytes until the first position that is a multiple of the page size. + $contentRange = $response->getHeader('Content-Range'); + // Matching "Content-Range: bytes 1234-5678/7890" + if (null !== $contentRange && preg_match('/^bytes\s([0-9]+)-([0-9]+)\//i', $contentRange, $matches)) { + // 4kB should be the default page size on most architectures + $pageSize = 4096; + $offset = (int) $matches[1]; + $delta = ($offset % $pageSize) > 0 ? ($pageSize - $offset % $pageSize) : 0; + if ($delta > 0) { + $left -= stream_copy_to_stream($body, $output, min($delta, $left)); } - while ($left > 0) { - $copied = stream_copy_to_stream($body, $output, min($left, $chunk_size)); - // stream_copy_to_stream($src, $dest, $maxLength) must return the number of bytes copied or false in case of failure - // But when the $maxLength is greater than the total number of bytes remaining in the stream, - // It returns the negative number of bytes copied - // So break the loop in such cases. - if ($copied <= 0) { - break; - } - $left -= $copied; - } - } else { - // workaround for 32 Bit systems to avoid stream_copy_to_stream - while (!feof($body)) { - fwrite($output, fread($body, 8192)); + } + while ($left > 0) { + $copied = stream_copy_to_stream($body, $output, min($left, $chunk_size)); + // stream_copy_to_stream($src, $dest, $maxLength) must return the number of bytes copied or false in case of failure + // But when the $maxLength is greater than the total number of bytes remaining in the stream, + // It returns the negative number of bytes copied + // So break the loop in such cases. + if ($copied <= 0) { + break; } + $left -= $copied; } } else { fwrite($output, $body, (int) $contentLength); @@ -215,7 +207,7 @@ class Sapi // Normalizing it to be prettier $header = strtolower(substr($key, 5)); - // Transforming dashes into spaces, and uppercasing + // Transforming dashes into spaces, and upper-casing // every first letter. $header = ucwords(str_replace('_', ' ', $header)); -- cgit v1.2.3