public function addHeader($key, $value = null, $toLower = true)
    {
        if (is_array($key)) {
            foreach ($key as $k => $v) {
                $this->addHeader($k, $v);
            }
        } else {
            if ($value !== null) {
                if ($toLower === true) {
                    $key = strtolower($key);
                }
                if (!isset($this->_headers[$key])) {
                    $this->_headers[$key] = $value;
                } else {
                    if (is_array($this->_headers[$key])) {
                        $this->_headers[$key][] = $value;
                    } else {
                        $this->_headers[$key] = [$this->_headers[$key], $value];
                    }
                }
            }
        }
    }
public function addHeader($key, $value = null, $toLower = true)
    {
        if (is_array($key)) {
            foreach ($key as $k => $v) {
                $this->addHeader($k, $v);
            }
        } else {
            if ($value !== null) {
                if ($toLower === true) {
                    $key = strtolower($key);
                }
                if (!isset($this->_headers[$key])) {
                    $this->_headers[$key] = $value;
                } else {
                    if (is_array($this->_headers[$key])) {
                        $this->_headers[$key][] = $value;
                    } else {
                        $this->_headers[$key] = [$this->_headers[$key], $value];
                    }
                }
            }
        }
    }
public function addHeader ( $ key , $ value = null , $ toLower = true ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ k => $ v ) { $ this -> addHeader ( $ k , $ v ) ; } } else { if ( $ value !== null ) { if ( $ toLower === true ) { $ key = strtolower ( $ key ) ; } if ( ! isset ( $ this -> _headers [ $ key ] ) ) { $ this -> _headers [ $ key ] = $ value ; } else { if ( is_array ( $ this -> _headers [ $ key ] ) ) { $ this -> _headers [ $ key ] [ ] = $ value ; } else { $ this -> _headers [ $ key ] = [ $ this -> _headers [ $ key ] , $ value ] ; } } } } }
Add http header or headers
@param mixed $key string key or key-value pairs to be added.
@param string $value the header value when key is string.
@param boolean $toLower convert key to lowercase
Add http header or headers