src/Viserio/Component/Http/AbstractMessage.php
public function withHeader($header, $value)
    {
        if (! \is_string($header)) {
            throw new InvalidArgumentException(\sprintf(
                'Invalid header name type; expected string; received [%s]',
                (\is_object($header) ? \get_class($header) : \gettype($header))
            ));
        }

        HeaderSecurity::assertValidName($header);

        $header     = \trim($header);
        $normalized = \strtolower($header);
        $new        = clone $this;

        // Remove the header lines.
        if ($new->hasHeader($header)) {
            unset($new->headers[$new->headerNames[$normalized]]);
        }

        // Add the header line.
        $new->headerNames[$normalized] = $header;
        $new->headers[$header]         = $this->filterHeaderValue($value);

        return $new;
    }
public function withHeader($header, $value)
    {
        if (! \is_string($header)) {
            throw new InvalidArgumentException(\sprintf(
                'Invalid header name type; expected string; received [%s]',
                (\is_object($header) ? \get_class($header) : \gettype($header))
            ));
        }

        HeaderSecurity::assertValidName($header);

        $header     = \trim($header);
        $normalized = \strtolower($header);
        $new        = clone $this;

        // Remove the header lines.
        if ($new->hasHeader($header)) {
            unset($new->headers[$new->headerNames[$normalized]]);
        }

        // Add the header line.
        $new->headerNames[$normalized] = $header;
        $new->headers[$header]         = $this->filterHeaderValue($value);

        return $new;
    }
{@inheritdoc}