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:----GB/0q/Wz3s1NvzSplIAKOytOxqAQTjXF/uxWW5pcY3DxkWLmVoprVj6BFL8yyzZSUl+k/KkHhyhb1LjrajKpfG7/+s2pfYP8ayog0UVL7cjXBuykI+IzANktmtJ8hQKe85MuugMJFsS9gGLUP6Y5YPwU01uivIS6l4FGHkZ6Fv2Mi6QX0I+enqCLmdCiemlLLe82UrdoW0Yjemau/XdvurBqItvMDHYWNzlV6ujTNO+j8MBQlt67i+FIaZ0Syn+OEQxGx9YcGuBY9+ZnbJQHmYODnxf09vVGG9/DU0fGu04ctTP5eVQGM752d9Xi1Ki0kgNyvE7b18NfcchDwkFzmfXTDxTt8n60ykYbyoNeyAcn2cvUp/B0qlRglR4fl7pa4CaH0v0G+/DeJDN4QGeku24WLTwiCajMSkDxupFCv4BuuGC97kY9NbAcPLXmKek45TUygB8MCb0t9UQdsn8hRrv1H4eTqXAlDWDZi5Bj/ss+oTQIVW7a0N1LXwTcia24i+zoOKzzRpIhyD6m0UXs1a0NK6GtSJY1/lHa0VKL2F/Fexu7GcfLWLuhD5jLkhIWQVQ/AZXTiaIooekLF2LzNrRZxWdmiH1B8QhFPTKfCTDgdjZOcmmbm9oui2O+eXISrYqOIs443l1o8F2QnkajbW8LtmGSNow0xF2+cMbi8bw=----ATTACHMENT:----NDg2MTk1MTk4ODU5NjczNCAyMDE2MTUzMDExMjg3MjE2IDIzMDMzNDMxNDgxMDAzNDY=