src/Http/Message.php
public function withHeader($name, $value)
    {
        $message = clone $this;
        $message->headers[(string)$name] = (array)$value;

        return $message;
    }
public function withHeader($name, $value)
    {
        $message = clone $this;
        $message->headers[(string)$name] = (array)$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|array $value Header value(s).
@return MessageInterface