src/Room11/HTTP/Response/Response.php
public function setHeader($field, $value)
    {
        if (!$field = @trim($field)) {
            throw new HTTPException(
                'Non-empty string field name required at Argument 1'
            );
        }

        $ucField = strtoupper($field);

        if ($ucField === 'SET-COOKIE') {
            $this->setCookieFromRawHeaderValue($value);

            return $this;
        } elseif (is_scalar($value) || is_null($value)) {
            $value = [(string) $value];
        } elseif (!(is_array($value) && $this->isValidArrayHeader($value))) {
            throw new HTTPException(
                'Invalid header; scalar or one-dimensional array of scalars required'
            );
        }

        if (isset($this->ucHeaders[$ucField])) {
            // There's already a case-insensitive match for this field name. Reuse the
            // existing case mapping.
            $field = $this->ucHeaders[$ucField];
        }

        $this->headers[$field] = $value;
        $this->ucHeaders[$ucField] = $field;

        return $this;
    }
public function setHeader($field, $value)
    {
        if (!$field = @trim($field)) {
            throw new HTTPException(
                'Non-empty string field name required at Argument 1'
            );
        }

        $ucField = strtoupper($field);

        if ($ucField === 'SET-COOKIE') {
            $this->setCookieFromRawHeaderValue($value);

            return $this;
        } elseif (is_scalar($value) || is_null($value)) {
            $value = [(string) $value];
        } elseif (!(is_array($value) && $this->isValidArrayHeader($value))) {
            throw new HTTPException(
                'Invalid header; scalar or one-dimensional array of scalars required'
            );
        }

        if (isset($this->ucHeaders[$ucField])) {
            // There's already a case-insensitive match for this field name. Reuse the
            // existing case mapping.
            $field = $this->ucHeaders[$ucField];
        }

        $this->headers[$field] = $value;
        $this->ucHeaders[$ucField] = $field;

        return $this;
    }
public function setHeader ( $ field , $ value ) { if ( ! $ field = @ trim ( $ field ) ) { throw new HTTPException ( 'Non-empty string field name required at Argument 1' ) ; } $ ucField = strtoupper ( $ field ) ; if ( $ ucField === 'SET-COOKIE' ) { $ this -> setCookieFromRawHeaderValue ( $ value ) ; return $ this ; } elseif ( is_scalar ( $ value ) || is_null ( $ value ) ) { $ value = [ ( string ) $ value ] ; } elseif ( ! ( is_array ( $ value ) && $ this -> isValidArrayHeader ( $ value ) ) ) { throw new HTTPException ( 'Invalid header; scalar or one-dimensional array of scalars required' ) ; } if ( isset ( $ this -> ucHeaders [ $ ucField ] ) ) { // There's already a case-insensitive match for this field name. Reuse the // existing case mapping. $ field = $ this -> ucHeaders [ $ ucField ] ; } $ this -> headers [ $ field ] = $ value ; $ this -> ucHeaders [ $ ucField ] = $ field ; return $ this ; }
Assign a header value

Existing values matching the specified field are replaced.
Header field names are NOT case-sensitive.

@param string $field
@param string $value
@throws \InvalidArgumentException
@return Response Returns the current object instance
Assign a header value