public function setBody($stringOrStream)
    {
        if ($stringOrStream instanceof RequestBody) {
            $this->body = $stringOrStream;
            $this->removeHeader("content-length");
            return;
        }

        if ($stringOrStream instanceof InputStream) {
            $this->body = new RequestBody($stringOrStream);
            $this->removeHeader("content-length");
            return;
        }

        try {
            // Use method with string type declaration, so we don't need to implement our own check.
            $this->setBodyFromString($stringOrStream ?? "");
        } catch (\TypeError $e) {
            // Provide a better error message in case of a failure.
            throw new \TypeError(\sprintf(
                "The request body must a string, null, or an instance of %s",
                InputStream::class
            ));
        }
    }