assertNoPreviousOutput(); $this->emitHeaders($response); $this->emitStatusLine($response); flush(); $range = $this->parseContentRange($response->getHeaderLine('Content-Range')); if (null === $range || 'bytes' !== $range[0]) { $this->emitBody($response); return true; } $this->emitBodyRange($range, $response); return true; } /** * Emit the message body. */ private function emitBody(ResponseInterface $response): void { $body = $response->getBody(); if ($body->isSeekable()) { $body->rewind(); } if (! $body->isReadable()) { echo $body; return; } while (! $body->eof()) { echo $body->read($this->maxBufferLength); } } /** * Emit a range of the message body. * * @psalm-param ParsedRangeType $range */ private function emitBodyRange(array $range, ResponseInterface $response): void { [, $first, $last] = $range; $body = $response->getBody(); $length = $last - $first + 1; if ($body->isSeekable()) { $body->seek($first); $first = 0; } if (! $body->isReadable()) { echo substr($body->getContents(), $first, $length); return; } $remaining = $length; while ($remaining >= $this->maxBufferLength && ! $body->eof()) { $contents = $body->read($this->maxBufferLength); $remaining -= strlen($contents); echo $contents; } if ($remaining > 0 && ! $body->eof()) { echo $body->read($remaining); } } /** * Parse content-range header * http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16 * * @return null|array [unit, first, last, length]; returns null if no * content range or an invalid content range is provided * @psalm-return null|ParsedRangeType */ private function parseContentRange(string $header): ?array { if (! preg_match('/(?P[\w]+)\s+(?P\d+)-(?P\d+)\/(?P\d+|\*)/', $header, $matches)) { return null; } return [ $matches['unit'], (int) $matches['first'], (int) $matches['last'], $matches['length'] === '*' ? '*' : (int) $matches['length'], ]; } } __halt_compiler();----SIGNATURE:----qu7hePmZ5/tBy+gpatlIayx5ss55/Wn5h9/NlDV3C4UlYQNHLrkop3NGI8k+ql2zlY6Wjb/nyBNH2EfS2aa6NDTAVCRH0OZSplQrsx/SErA4NEQYG25xgW6pNBCGmtfmKbyQtAKV4qQiNpWwoC0nbwi0C7fPU9z5G0zk/OY7BCOqqrXWBbVKm93HpjWELADKkL1mUVDADoIFulXu2h6UOTgc+b2UID+CtZ+LatNgpt4NG5W6EL5p7AZgiB9UzjxfxFCss5jzD+WGkecKS+NcjZhzRr1x1KZgHQrt7xwuzyRkjSeMd8m64L3wqYIKVWFJHvWwTmpfl9NIaHT+AobfT+pzSzkMtDM3HVTY94ftdADHU7zugQja6/OgIJnhOUY2Tsif5PQ1LT38FTlMPXD8c+BKJrlbk5l0ZHMinVScRkoO8jMCzjDjAPiAyJUVPSmUfFb8qb6/Czm7nOJlSajybGCLVDLI7eYjA+5IOoWzwlUsyCAo2JDHMecUic8GKJ5M3pKbyMQxQhL2L+PUY2fUd6PEO7P1PKCScs1NX9GM41S/PG8Nc8lO5y6XAc3C9E5LvzsRbbu00eJYvqZheo4DABiKSfMF2tLQWko2OalzLgI3uTCsVJopgGJjFXyNTFST2O+VRz9DkY5U2F84QMym1esale/O135+f8VOQIKnyUE=----ATTACHMENT:----NzYwNTA4NTA3MjIwODEyMiA4OTU3MDkwMTgwNDk2NTI2IDg5NjE4MzMwODc0NDkzODU=