src/Valkyrja/HttpMessage/MessageTrait.php
public function withHeader(string $name, string ...$values)
    {
        HeaderSecurity::assertValidName($name);

        $normalized = strtolower($name);

        $new = clone $this;

        if ($new->hasHeader($name)) {
            unset($new->headers[$new->headerNames[$normalized]]);
        }

        $values = $this->assertHeaderValues(...$values);

        $new->headerNames[$normalized] = $name;
        $new->headers[$name]           = $values;

        return $new;
    }
public function withHeader(string $name, string ...$values)
    {
        HeaderSecurity::assertValidName($name);

        $normalized = strtolower($name);

        $new = clone $this;

        if ($new->hasHeader($name)) {
            unset($new->headers[$new->headerNames[$normalized]]);
        }

        $values = $this->assertHeaderValues(...$values);

        $new->headerNames[$normalized] = $name;
        $new->headers[$name]           = $values;

        return $new;
    }
Return an instance with the provided value replacing the specified
header.

While header names are case-insensitive, the casing of the header will
be preserved by this function, and returned from getHeaders().

This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that has the
new and/or updated header and value.

@param string   $name      Case-insensitive header field name.
@param string[] ...$values Header values.

@throws \InvalidArgumentException for invalid header names or values.

@return static