public function withProtocolVersions(array $versions): self {
        $versions = \array_unique($versions);

        if (empty($versions)) {
            throw new \Error("Empty array of protocol versions provided, must not be empty.");
        }

        foreach ($versions as $version) {
            if (!\in_array($version, ["1.0", "1.1", "2.0"], true)) {
                throw new \Error(
                    "Invalid HTTP protocol version: " . $version
                );
            }
        }

        if ($this->protocolVersions === $versions) {
            return $this;
        }

        $clone = clone $this;
        $clone->protocolVersions = $versions;

        return $clone;
    }