protected function sendContent()
    {
        $body = $this->getBody();
        if (!$body->isReadable()) {
            throw new \RuntimeException('Unable to send content: body stream is not readable.');
        }

        set_time_limit(0); // Reset time limit for big files
        $chunkSize = 8 * 1024 * 1024; // 8MB per chunk

        if (is_array($this->bodyRange)) {
            [$begin, $end] = $this->bodyRange;

            if (!$body->isSeekable()) {
                throw new \RuntimeException('Unable to send content in range: body stream is not seekable.');
            }

            $body->seek($begin);
            while (!$body->eof() && ($pos = $body->tell()) <= $end) {
                if ($pos + $chunkSize > $end) {
                    $chunkSize = $end - $pos + 1;
                }
                echo $body->read($chunkSize);
                flush(); // Free up memory. Otherwise large files will trigger PHP's memory limit.
            }
            $body->close();
        } else {
            if ($body->isSeekable()) {
                $body->seek(0);
            }
            while (!$body->eof()) {
                echo $body->read($chunkSize);
                flush(); // Free up memory. Otherwise large files will trigger PHP's memory limit.
            }
            $body->close();
            return;
        }
    }
protected function sendContent()
    {
        $body = $this->getBody();
        if (!$body->isReadable()) {
            throw new \RuntimeException('Unable to send content: body stream is not readable.');
        }

        set_time_limit(0); // Reset time limit for big files
        $chunkSize = 8 * 1024 * 1024; // 8MB per chunk

        if (is_array($this->bodyRange)) {
            [$begin, $end] = $this->bodyRange;

            if (!$body->isSeekable()) {
                throw new \RuntimeException('Unable to send content in range: body stream is not seekable.');
            }

            $body->seek($begin);
            while (!$body->eof() && ($pos = $body->tell()) <= $end) {
                if ($pos + $chunkSize > $end) {
                    $chunkSize = $end - $pos + 1;
                }
                echo $body->read($chunkSize);
                flush(); // Free up memory. Otherwise large files will trigger PHP's memory limit.
            }
            $body->close();
        } else {
            if ($body->isSeekable()) {
                $body->seek(0);
            }
            while (!$body->eof()) {
                echo $body->read($chunkSize);
                flush(); // Free up memory. Otherwise large files will trigger PHP's memory limit.
            }
            $body->close();
            return;
        }
    }
protected function sendContent ( ) { $ body = $ this -> getBody ( ) ; if ( ! $ body -> isReadable ( ) ) { throw new \ RuntimeException ( 'Unable to send content: body stream is not readable.' ) ; } set_time_limit ( 0 ) ; // Reset time limit for big files $ chunkSize = 8 * 1024 * 1024 ; // 8MB per chunk if ( is_array ( $ this -> bodyRange ) ) { [ $ begin , $ end ] = $ this -> bodyRange ; if ( ! $ body -> isSeekable ( ) ) { throw new \ RuntimeException ( 'Unable to send content in range: body stream is not seekable.' ) ; } $ body -> seek ( $ begin ) ; while ( ! $ body -> eof ( ) && ( $ pos = $ body -> tell ( ) ) <= $ end ) { if ( $ pos + $ chunkSize > $ end ) { $ chunkSize = $ end - $ pos + 1 ; } echo $ body -> read ( $ chunkSize ) ; flush ( ) ; // Free up memory. Otherwise large files will trigger PHP's memory limit. } $ body -> close ( ) ; } else { if ( $ body -> isSeekable ( ) ) { $ body -> seek ( 0 ) ; } while ( ! $ body -> eof ( ) ) { echo $ body -> read ( $ chunkSize ) ; flush ( ) ; // Free up memory. Otherwise large files will trigger PHP's memory limit. } $ body -> close ( ) ; return ; } }
Sends the response content to the client.
Sends the response content to the client .