Sets a header, replacing any existing values of any headers with the same case-insensitive name.

The header value MUST be a string or an array of strings.

@param string       $name
@param string|array $value

@return static
173766
public function setHeader(string $name, $value) : Message
    {
        $name = strtolower($name);
        $this->headers[$name] = is_array($value) ? array_values($value) : [$value];

        return $this;
    }
1344070
final public function withHeader($name, $value): self
    {
        $message = clone $this;

        //Make sure to remove the current header with the same
        //name to avoid casing-duplication (location, Location, LOCATION)
        if ($message->hasHeader($name)) {
            $message = $message->withoutHeader($name);
        }

        $message->addHeaders([$name => $value]);
        return $message;
    }
875690
public function set(string $name, string $value)
    {
        $this->values[$name] = $value;
        return $this;
    }
365585
public function setHeader($name, $value)
    {
        $context = $this->_context;

        $context->headers[$name] = $value;

        return $this;
    }
322241
public function setHeader(string $name, string $value)
    {
        // Make sure the word has no spaces but dashes instead, and is
        // Camel-Cased. The dashes are first replaced with spaces to let
        // ucwords function properly, and afterwards all spaces are converted
        // to dashes.
        $name = ucwords(strtolower(str_replace('-', ' ', $name)));
        $name = str_replace(' ', '-', $name);

        $this->headers[$name] = $value;
        return $this;
    }
517435
public function set($name, $value = null)
	{
		is_null($name) or \Arr::set($this->data, $name, $value);

		return $this;
	}
1073
public function set($name, $value = null)
    {
        if (is_array($name)) {
            $this->parameters = array_replace($this->parameters, $name);
        } else {
            $this->parameters[trim(strtolower($name))] = is_string($value) ? trim($value) : $value;
        }
    }
854819
public function header($name, $value=null) 
    {
        if (is_array($name)) {
            $this->def['header'] = array_merge($this->def['header'], $name);
        } else {
            $this->def['header'][$name] = $value;
        }
        return $this;
    }
182296
public function setHeader($name, $value, $replace = false)
    {
        // Add multiple headers for the reponse as array
        if (is_array($name)) {
            foreach ($name as $headerKey => $headerValue) {
                $this->headers->set($headerKey, $headerValue, $replace);
            }

            return $this;
        }

        $this->headers->set($name, $value, $replace);

        return $this;
    }
818455
public function withHeader($name, $value): self
    {
        $this->assertHeaderName($name);

        $clone = clone $this;
        $clone->headers->set($name, $value);

        if ($clone->getStatusCode() === 200 && strtolower($name) === 'location') {
            $clone = $clone->withStatus(302);
        }

        return $clone;
    }
351310
public function withHeader($name, $value)
    {
        $new = clone $this;
        $name = $this->normalizeHeaderName($name);
        $new->_environment[$name] = $value;

        return $new;
    }
718201
public function withHeader($name, $value): self
    {
        $this->assertHeaderName($name);

        $clone = clone $this;
        $clone->headers->set($name, $value);

        return $clone;
    }
997985
protected function addHeader(string $name, $value)
    {
        \assert($this->isNameValid($name), "Invalid header name");

        if (\is_array($value)) {
            if (!$value) {
                return;
            }

            $value = \array_values(\array_map("strval", $value));
        } else {
            $value = [(string) $value];
        }

        \assert($this->isValueValid($value), "Invalid header value");

        $name = \strtolower($name);
        if (isset($this->headers[$name])) {
            $this->headers[$name] = \array_merge($this->headers[$name], $value);
        } else {
            $this->headers[$name] = $value;
        }
    }
672165
public function replace($name, $value = '')
    {
        Types::assert(['string' => [$name, $value]]);

        $header = HeaderFactory::build($name, $value);
        $this->headers[strtolower($name)] = [$header];
    }
1175928
public final function setHeader($name, $value)
    {
        self::checkString($name);
        self::checkString($value);

        $this->_headers[$name] = $value;
    }
865785
public final function header(string $name, string $value = null)
    {
        return ($value === null) ? $this->getHeader($name) : $this->setHeader($name, $value);
    }
1001517
public function withHeader($name, $value) : self
    {
        $new = clone $this;

        return $new->setResponse($this->response->withHeader($name, $value));
    }