public function finish(Request $request) : Response
    {
        if ($this->finished) {
            throw new \LogicException('The response has already finished.');
        }

        $this->request = $request;

        $this->headers->set('content-length', strlen($this->body));
        $this->setEmptyResponse();

        $this->writeHeaders();
        $this->writeBody();

        $this->finished = true;

        return $this;
    }