public function flush(): void
    {
        $this->prepareFlush();
        $this->runBeforeFlush();

        $path = $this->getViewPath($this->view);

        if (!file_exists($path)) {
            throw new ResponseException("View ({$this->view}) not found on path={$path}");
        }

        ob_start(null, 0, PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_FLUSHABLE | PHP_OUTPUT_HANDLER_REMOVABLE);

        require $path;

	    $statusCode = $this->statusCode;
	    $statusCodeIs1XX = $statusCode >= 100 && $statusCode <= 199;

	    if (!$statusCodeIs1XX && $statusCode !== 204) {
		    $size = ob_get_length();
		    $this->setHeader('Content-Length', $size);
	    }

        $this->flushBuffer();

        $this->runAfterFlush();
    }