Sets a header by name.

@param string       $key     The key
@param string|array $values  The value or an array of values
@param Boolean      $replace Whether to replace the actual value or not (true by default)
15788
public function set($key, $values, $replace = true)
    {
        $key = strtr(strtolower($key), '_', '-');

        $values = array_values((array) $values);

        if (true === $replace || !isset($this->headers[$key])) {
            $this->headers[$key] = $values;
        } else {
            $this->headers[$key] = array_merge($this->headers[$key], $values);
        }

        if ('cache-control' === $key) {
            $this->cacheControl = $this->parseCacheControl($values[0]);
        }
    }
1137890
public static function toTail(array &$values, $key) {
    $key = (array) $key;

    $keys = array_keys($values);
    $keys = array_diff($keys, $key);
    $keys = array_merge($keys, $key);

    static::order($values, $keys);
  }
1057351
public function setHeader($key, $value, $replace = true, $http_response_code = null)
    {
        $this->swooleResponse->header($key. $value);
    }
593167
public function setShape($value, $replace = true)
    {
        $name = 'shapes';
        if (!(is_array($value) || is_string($value))) {
            throw new CPS_Exception(array(array('long_message' => 'Invalid request parameter', 'code' => ERROR_CODE_INVALID_PARAMETER, 'level' => 'REJECTED', 'source' => 'CPS_API')));
        }
        if ($replace) {
            $this->_setRawParam($name, $value);
        } else {
            $exParam = $this->_getRawParam($name);
            if (!is_array($exParam)) {
                $exParam = array($exParam);
            }
            if (is_array($value)) {
                foreach($value as $val){
                    $exParam[] = $val;
                }
            } else if (is_string($value)) {
                $exParam[] = $value;
            }
            $this->_setRawParam($name, $exParam);
        }
    }
687360
function(key, value) {
          const key2 = key.toLowerCase().replace(/[^a-z0-9]/ig, '');
          res.serverassist.headers[key]    = value;
          res.serverassist.headers2[key2]  = value;
        }
834312
function set($key,$val) {
		$key=$this->fixheader($key);
		return $this->headers[$key]=$val;
	}
761755
final protected static function replaceKey($data, $search, $replace)
    {
        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $data[$key] = $value = self::replaceKey($data[$key], $search, $replace);
            }
            if ($key == $search) {
                $data[$replace] = $value;
                unset($data[$search]);
            }
        }

        return $data;
    }
204843
public function sendHeader($name, $value, $replace = true)
    {
        @header($name . ': ' . trim($value), $replace);

        return $this;
    }
501580
public function withHeader($key, $value, $replace = true)
    {
        return $this->header($key, $value, $replace);
    }
1000498
protected function replacePlaceholders(
        /*# string */ $key,
        array &$bindings,
        array $settings
    )/*# : string */ {
        $escape = $this->escape;

        $value = $this->parameters[$key];
        if ($settings['positionedParam']) {
            $bindings[] = $value;
            return '?';
        } elseif ($settings['namedParam'] && $this->isNamedParam($value)) {
            return $value;
        } else {
            return $escape($value);
        }
    }
986229
public function setHeader($key, $value = null, $toLower = true)
    {
        if (is_array($key)) {
            foreach ($key as $k => $v) {
                $this->setHeader($k, $v);
            }
        } else {
            if ($toLower === true) {
                $key = strtolower($key);
            }
            if ($value === null) {
                unset($this->_headers[$key]);
            } else {
                $this->_headers[$key] = $value;
            }
        }
    }
716808
public function addHeader($key, $value = null)
    {
        //if it's an array
        if (is_array($key)) {
            //warning this overwrites existing headers
            $this->headers = $key;
            return $this;
        }

        //if the value is null
        if (is_null($value)) {
            $this->headers[] = $key;
            return $this;
        }

        //else it should be key value
        $this->headers[] = $key . ': ' . $value;
        return $this;
    }
203194
public function add($key, $value)
    {
        $header = $this->get($key, true);
        if (is_array($value)) {
            $header = array_merge($header, $value);
        } else {
            $header[] = $value;
        }
        parent::set($this->normalizeKey($key), $header);
    }
921235
public function setHeaders(array $headers = [], $append = true, $replaceExisting = true)
    {
        if (!$append) {
            $this->headers = $headers;
            return $this;
        }
        
        foreach ($headers as $key => $value) {
            /** If the header is already set then check if we can replace the value. */
            if (isset($this->headers[$key]) && (false == $replaceExisting)) {
                continue;
            }
            
            $this->headers[$key] = $value;
        }
        
        return $this;
    }
1211741
public function header($key, $value, $replace = true)
	{
		if (empty($this->headers[$key]))
		{
			$this->headers[$key] = array();
		}
		if ($replace)
		{
			$this->headers[$key] = array($value);
		}
		else
		{
			$this->headers[$key][] = $value;
		}

		return $this;
	}
216285
public function setHeaders(array $headers, $replace = false)
    {
        if ($replace) {
            $this->headers = $headers;
        } else {
            foreach ($headers as $key => $value) {
                $this->headers[$key] = $value;
            }
        }

        return $this;
    }
559866
protected function setKey($key, $value)
    {
        $key = strtolower((string)$key);
        $this->keys[$key] = (string)$value;
    }