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
510920
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;
    }
200985
public function assertInputValue($field, $value)
    {
        PHPUnit::assertEquals(
            $value, $this->inputValue($field),
            "Expected value [{$value}] for the [{$field}] input does not equal the actual value [{$this->inputValue($field)}]."
        );

        return $this;
    }
47129
public function in($field, $value) {
        $this->add($field, Expr::IN, (array) $value);

        return $this;
    }
1267486
public function addHeader ($header, $value = null)
		{
			if ($value)
				$this->_headers[] = "$header: $value";
			else
				$this->_headers[] = $header;

			return $this;
		}
1100411
public function setResult($field, $value)
    {
        if (!isset($this->results[$field])) {
            $this->results[$field] = $value;
        }

        return $this;
    }
1112795
public function setFieldValue(string $field, int $value) : bool
        {
                return $this->_redis->zadd($this->_key, $value, $field) > 0 ? true : false;
        }
1219293
protected function prepareHeaderValue($value)
    {
        if (is_string($value)) {
            $value = [$value];
        }
        if (! is_array($value)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid header value "%s"; must be a string or array of strings.',
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }
        foreach ($value as &$item) {
            if (! is_string($item)) {
                throw new InvalidArgumentException(sprintf(
                    'Invalid header value "%s"; must be a string.',
                    is_object($item) ? get_class($item) : gettype($item)
                ));
            }

            $item = trim($item);

            if ('' === $item) {
                throw new InvalidArgumentException(
                    'Empty header value provided.'
                );
            }

            if (preg_match('/[^\x09\x0a\x0d\x20-\x7E\x80-\xFE]/', $item)) {
                throw new InvalidArgumentException(sprintf(
                    'The header value "%s" contains illegal characters.',
                    $item
                ));
            }
            $item = preg_replace('/\s+/', ' ', $item);
        }

        return $value;
    }
1221367
public function setFieldValue($name, $value)
    {
        foreach ($this->fields as $key => $fields) {
            if (isset($fields[$name])) {
                $this->fields[$key][$name]->setValue($value);
            }
        }
        return $this;
    }
131123
public function setField(string $field) : void
    {
        $field = trim($field);
        if (empty($field)) {
            throw new InvalidArgumentException("Field is empty");
        }

        $this->field = $field;
    }
1148472
public function withAddedHeader($header, $value)
    {
        // Follow a different procedure if the given header isn't set yet at all.
        if (!$this->hasHeader($header)) {
            return $this->withHeader($header, $value);
        }

        // Normalize the header name.
        $name   = strtolower($header);
        $header = $this->headerNames[$name];

        // Create a clone and append the value to the specified header's values.
        $new = clone $this;
        $new->headers[$header] = array_merge($this->headers[$header], (array) $value);

        return $new;
    }
341843
public function set($field, $value = UNDEFINED)
    {
        if ($value === false) {
            throw $this->exception('Value "false" is not supported by SQL')
                ->addMoreInfo('field', $field);
        }
        if (is_array($field)) {
            foreach ($field as $key => $value) {
                $this->set($key, $value);
            }

            return $this;
        }

        if ($value === UNDEFINED) {
            throw $this->exception('Specify value when calling set()');
        }

        $this->args['set'][$field] = $value;

        return $this;
    }
304099
public function header($header = null, $value = null) {
        if ($header === null) {
            $this->headers = [];
        } else if ($value === null) {
            unset($this->headers[ $header ]);
        } else {
            $this->headers[ $header ] = $header . ': ' . $value;
        }

        return $this;
    }
1217330
public function header($name, $value = null)
    {

        if ($value === null) {
            $this->headers[] = $name;
        } else {
            $this->headers[] = $this->headerString($name, $value);
        }

        return $this;
    }
1046756
public function header($header, $value = null)
    {
        if (is_array($header)) {
            $this->option['header'] = $header;
        } else {
            $this->option['header'][$header] = $value;
        }

        return $this;
    }
1221310
public function setHeader(string $header, string $value)
  {
    $found = false;
    # Traverse the headers, searching for a matching header (case insensitive)
    foreach ( $this->headers as $idx => $oldValue )
    {
      if (strcasecmp($this->headers[$idx],$header)==0)
      {
        # Found the header, now replace the value
        $found = true;
        $this->headers[$idx] = $value;
        break;
      }
    }
    # Add the header
    if (!$found) {
      $this->headers[$header] = $value;
    }

    return $this;
  }
306962
public function setValue($value)
    {
        if (is_numeric($value)) {
            $value = (string) $value;
        }

        if (!is_string($value) && $value !== null) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, (is_object($value) ? get_class($value) : gettype($value))));
        }

        $this->node->nodeValue = $value;

        return $this;
    }
244732
public function type($field, $value)
    {
        $this->resolver->resolveForTyping($field)->clear()->sendKeys($value);

        return $this;
    }