private function writeResponse(int $requestId, string $headerData, $stream): void
    {
        $data = $headerData;
        $eof  = false;
        $maxSize = 65535;
        fseek($stream, 0, SEEK_SET);

        do {
            $dataLength = strlen($data);

            if ($dataLength < $maxSize && !$eof && !($eof = feof($stream))) {
                $readLength  = $maxSize - $dataLength;
                $data       .= fread($stream, $readLength);
                $dataLength  = strlen($data);
            }

            $writeSize = min($dataLength, $maxSize);
            $writeData = substr($data, 0, $writeSize);
            $data      = substr($data, $writeSize);

            $this->writeRecord($requestId, DaemonInterface::FCGI_STDOUT, $writeData);
        } while ($writeSize === $maxSize);

        $this->writeRecord($requestId, DaemonInterface::FCGI_STDOUT);
    }
private function writeResponse(int $requestId, string $headerData, $stream): void
    {
        $data = $headerData;
        $eof  = false;
        $maxSize = 65535;
        fseek($stream, 0, SEEK_SET);

        do {
            $dataLength = strlen($data);

            if ($dataLength < $maxSize && !$eof && !($eof = feof($stream))) {
                $readLength  = $maxSize - $dataLength;
                $data       .= fread($stream, $readLength);
                $dataLength  = strlen($data);
            }

            $writeSize = min($dataLength, $maxSize);
            $writeData = substr($data, 0, $writeSize);
            $data      = substr($data, $writeSize);

            $this->writeRecord($requestId, DaemonInterface::FCGI_STDOUT, $writeData);
        } while ($writeSize === $maxSize);

        $this->writeRecord($requestId, DaemonInterface::FCGI_STDOUT);
    }
private function writeResponse ( int $ requestId , string $ headerData , $ stream ) : void { $ data = $ headerData ; $ eof = false ; $ maxSize = 65535 ; fseek ( $ stream , 0 , SEEK_SET ) ; do { $ dataLength = strlen ( $ data ) ; if ( $ dataLength < $ maxSize && ! $ eof && ! ( $ eof = feof ( $ stream ) ) ) { $ readLength = $ maxSize - $ dataLength ; $ data .= fread ( $ stream , $ readLength ) ; $ dataLength = strlen ( $ data ) ; } $ writeSize = min ( $ dataLength , $ maxSize ) ; $ writeData = substr ( $ data , 0 , $ writeSize ) ; $ data = substr ( $ data , $ writeSize ) ; $ this -> writeRecord ( $ requestId , DaemonInterface :: FCGI_STDOUT , $ writeData ) ; } while ( $ writeSize === $ maxSize ) ; $ this -> writeRecord ( $ requestId , DaemonInterface :: FCGI_STDOUT ) ; }
Write a response to the connection as FCGI_STDOUT records.

@param int      $requestId  The request id to write to
@param string   $headerData The header -data to write (including terminating CRLFCRLF)
@param resource $stream     The stream to write
Write a response to the connection as FCGI_STDOUT records .