AppserverIo\Appserver\ServletEngine\Http\Response::addHeader PHP Метод

addHeader() публичный Метод

Adds a header information got from connection. We've to take care that headers like Set-Cookie header can exist multiple times. To support this create an array that keeps the multiple header values.
public addHeader ( string $name, string $value, boolean $append = false ) : void
$name string The header name
$value string The headers value
$append boolean If TRUE and a header with the passed name already exists, the value will be appended
Результат void
    public function addHeader($name, $value, $append = false)
    {
        // normalize header names in case of 'Content-type' into 'Content-Type'
        $name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $name)));
        // check if we've a Set-Cookie header to process
        if ($this->hasHeader($name) && $append === true) {
            // then check if we've already one cookie header available
            if (is_array($headerValue = $this->getHeader($name))) {
                $headerValue[] = $value;
            } else {
                $headerValue = array($headerValue, $value);
            }
            // if no cookie header simple add it
            $this->headers[$name] = $headerValue;
        } else {
            $this->headers[$name] = $value;
        }
    }