public function sendHeaders()
    {
        if (php_sapi_name() !== "cli" && headers_sent($file, $line)) {
            throw new Exception("Try to send headers but headers already sent, output started at $file line $line.");
        }

        http_response_code($this->statusCode);

        foreach ($this->headers as $header) {
            if (php_sapi_name() !== "cli") {
                header($header);
            }
        }

        return $this;
    }