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:----oEYJKXh5qbGEw9qrMmfkvGlCGIsuCST2MKhDLebkievCJmLE4yHznofE8Mj3uBkE8w/1AY4tTDJ5CLvm2LPTz+rl86/iqWrTlfuR4WbSBXb8T50JGjm0ymNCqW/cu8oo4GCzqBbPHkleTpE86YN1T2ieh8eC1W5AE0cOO7aWzNmdjfAk9w8IMX7DsvC2bPJNZFJP/wmmSGyRynxnoPdl3zeZD+b9jbcPwGFIrkFkz7evj+iAOdfvLTbPzXkj06K/99hqsRzY2qXdXBMRfbLBe/sMtph94C/bTn55gpB6yldt9RvaIfqoHoRT8ycNNRHb6xxtlUtWpBNrmJjrWqf3yrhz5oqRNfeM972g3ZH2ZCd7L6IvBcTWdLPjfbnkpCGBxiRcM2pQ1Jh7NdgTQvCy3GEfhdEbIeb9GQ39xKI46ofpv9NiWENjjiHfIIw81RjFCXsfmlAKxoUJuOocL15TLX1k7N0noh5s6ltCQ2jCICNg9KaLN2iIf4vfihLn2fQOLCC6t/9KF65uH8p0ByW+cJjhszaP+K4kATkb8X32EHKxEy+CTislsXjKQqs7YrFlnaKqK9DOdTjzSycnSVgbSSdDEaVfvW/a5i21fNzWvngN2VAdp4uhO/fozoYmH4M5CZ4T2XUF1EzNg66Yke1Lca0eZZ8LkTn3iFTea87hvlw=----ATTACHMENT:----MjE3Nzc3MzIwOTU3NzkxMyAzMDUzODI1MzAwODY0NzQ3IDYzNjE1MTE0MTE4OTA2MDM=