private function writeRecord(int $requestId, int $type, string $content = null): void
    {
        $contentLength = null === $content ? 0 : strlen($content);

        $headerData = pack('CCnnxx', DaemonInterface::FCGI_VERSION_1, $type, $requestId, $contentLength);

        $this->connection->write($headerData);

        if (null !== $content) {
            $this->connection->write($content);
        }
    }