public function addHeader($headerLine)
    {
        $parts = explode(':', $headerLine, 2);
        if (2 !== count($parts)) {
            throw new \InvalidArgumentException(
                sprintf('"%s" is not a valid HTTP header line', $headerLine)
            );
        }
        $name = trim($parts[0]);
        $value = trim($parts[1]);
        if ($this->response->hasHeader($name)) {
            $this->response = $this->response->withAddedHeader($name, $value);
        } else {
            $this->response = $this->response->withHeader($name, $value);
        }

        return $this;
    }
public function addHeader($headerLine)
    {
        $parts = explode(':', $headerLine, 2);
        if (2 !== count($parts)) {
            throw new \InvalidArgumentException(
                sprintf('"%s" is not a valid HTTP header line', $headerLine)
            );
        }
        $name = trim($parts[0]);
        $value = trim($parts[1]);
        if ($this->response->hasHeader($name)) {
            $this->response = $this->response->withAddedHeader($name, $value);
        } else {
            $this->response = $this->response->withHeader($name, $value);
        }

        return $this;
    }
public function addHeader ( $ headerLine ) { $ parts = explode ( ':' , $ headerLine , 2 ) ; if ( 2 !== count ( $ parts ) ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" is not a valid HTTP header line' , $ headerLine ) ) ; } $ name = trim ( $ parts [ 0 ] ) ; $ value = trim ( $ parts [ 1 ] ) ; if ( $ this -> response -> hasHeader ( $ name ) ) { $ this -> response = $ this -> response -> withAddedHeader ( $ name , $ value ) ; } else { $ this -> response = $ this -> response -> withHeader ( $ name , $ value ) ; } return $ this ; }
Add header represented by a string.

@param string $headerLine Response header as a string.

@return $this

@throws \InvalidArgumentException For invalid header names or values.
Add header represented by a string .