src/Message/Message.php
public function withHeader($name, $value)
    {
        $key = $this->headerKey($name);

        $message = clone $this;
        $message->headers[$key] = is_array($value) ? $value : [$value];
        return $message;
    }
public function withHeader($name, $value)
    {
        $key = $this->headerKey($name);

        $message = clone $this;
        $message->headers[$key] = is_array($value) ? $value : [$value];
        return $message;
    }
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|string[] $value Header value(s).
@return static
@throws \InvalidArgumentException for invalid header names or values.