处理header.
(支持两种header格式)

@param $value
@return array
332453
private function getHeader($value)
    {
        if (!$value) {
            return [];
        }
        $newHeader = [];
        foreach ($value as $key => $item) {
            if (is_string($key)) {
                $newHeader[] = $key . ': ' . $item;
            } else {
                $newHeader[] = $item;
            }
        }
        return $newHeader;
    }
19738
private function markIn($value): array
    {
        // 已经是数组,直接返回
        if (is_array($value)) {
            return $value;
        }

        // 除了数组,只能是字符串
        if (!is_string($value)) {
            trigger_error('in运算符的值必须是字符串或数组:' . json($value), E_USER_ERROR);
        }

        // 尝试按逗号分解
        $arr = explode(',', $value);
        if (count($arr) > 1) {
            return $arr;
        }

        // 尝试按空格分解
        $arr = explode(' ', $value);
        if (count($arr) > 1) {
            return $arr;
        }

        // 看来只能是单值了
        return [$value];
    }
317080
public function push($headers, $value = '')
    {
        if (is_string($headers) && func_num_args() === 2) {
            $headers = [$headers => $value];
        }
        return $this->_set($headers);
    }
1105629
public function header($key, $value = null)
	{
		if( is_null($value) )
		{
			$pos = strpos($key, ":");
			if( ! $pos )
			{
				return $this;
			}

			$value = substr($key, $pos + 1);
			$key = substr($key, 0, $pos);
		}
		$this->headers->set($key, $value);
		return $this;
	}
729081
private function formatValueForApi($value)
    {
        $type = gettype($value);

        switch ($type) {
            case 'string':
                return ['string_value' => $value];
            case 'double':
            case 'integer':
                return ['number_value' => $value];
            case 'boolean':
                return ['bool_value' => $value];
            case 'NULL':
                return ['null_value' => NullValue::NULL_VALUE];
            case 'array':
                if (!empty($value) && $this->isAssoc($value)) {
                    return ['struct_value' => $this->formatStructForApi($value)];
                }

                return ['list_value' => $this->formatListForApi($value)];
        }
    }
741708
public function header($name, $value = null)
    {
        if (func_num_args() < 2) {
            return $this->request->getHeader($name);
        }
        if (is_null($value)) {
            $this->response->withoutHeader($name);
        } else {
            $this->setHeader($name, $value);
        }
        return $this;
    }
721178
public function header( $key, $value = null ) {

		$key = explode( '-', $key );
		foreach( $key as $k => $v ) {
			$key[$k] = ucfirst( strtolower($v));
		}
		$key = implode( '-', $key );

		if ( !is_null( $value ) ) {
			$this->_headers[$key] = $value;
		}

		return $this->_headers[$key];
	}
1201645
public function setHeader($name, $value)
    {
        $internalName = strtolower($name);

        if (true === is_array($value)) {
            $this->headers[$internalName] = $value;
        } else {
            $this->headers[$internalName] = array($value);
        }
    }
1046176
public function filter($value)
    {
        if (!is_scalar($value) && !is_array($value)) {
            return $value;
        }

        // a unicode safe way of converting characters to \x00\x00 notation
        $pregQuotedSeparator = preg_quote($this->separator, '#');

        if (StringUtils::hasPcreUnicodeSupport()) {
            $patterns = [
                '#(' . $pregQuotedSeparator.')(\P{Z}{1})#u',
                '#(^\P{Z}{1})#u',
            ];
            if (!extension_loaded('mbstring')) {
                $replacements = [
                    function ($matches) {
                        return strtoupper($matches[2]);
                    },
                    function ($matches) {
                        return strtoupper($matches[1]);
                    },
                ];
            } else {
                $replacements = [
                    function ($matches) {
                        return mb_strtoupper($matches[2], 'UTF-8');
                    },
                    function ($matches) {
                        return mb_strtoupper($matches[1], 'UTF-8');
                    },
                ];
            }
        } else {
            $patterns = [
                '#(' . $pregQuotedSeparator.')([\S]{1})#',
                '#(^[\S]{1})#',
            ];
            $replacements = [
                function ($matches) {
                    return strtoupper($matches[2]);
                },
                function ($matches) {
                    return strtoupper($matches[1]);
                },
            ];
        }

        $filtered = $value;
        foreach ($patterns as $index => $pattern) {
            $filtered = preg_replace_callback($pattern, $replacements[$index], $filtered);
        }
        return $filtered;
    }
1076537
public static function getFormatValue($value) {

        if ( $value instanceof \MongoId ) return $value;

        $opt = substr($value, 0, 2);
        //1.包含双字符操作符的
        if ( isset(self::$operator[$opt]) ) {
            //获取真正的value
            $_value = substr($value, 2);
            return array(self::$operator[$opt] => $_value);
        }

        //2.包含单字符操作符的
        if ( isset(self::$operator[$value[0]]) ) {
            //获取真正的value
            $_value = substr($value, 1);
            return array(self::$operator[$value[0]] => $_value);
        }

        return $value;
    }
588740
public function setHeaders($key, $value = null)
    {
        if (is_array($key)) {
            $this->headers = $key;
            return $this;
        }

        $this->headers[] = $key.': '.$value;
        return $this;
    }
108729
public function addGenericHeader($header, $value)
    {
        $this->_headers[] = sprintf(
            '%s: %s',
            (string) $header,
            (string) $value
        );
        return $this;
    }
401413
public function addHeader($header, $value)
    {
        $name = strtolower($header);

        if(is_array($value))
        {
            foreach($value as $v)
                $this->headers[$name][] = trim($v);

            foreach(array_keys($this->headerLines) as $key)
                if(strtolower($key) == $name)
                    unset($this->headerLines[$key]);

            $this->headerLines[$header] = $this->headers[$name];
        }
        else
        {
            $this->headers[$name][] = trim($value);

            foreach(array_keys($this->headerLines) as $key)
                if(strtolower($key) == $name)
                    unset($this->headerLines[$key]);

            $this->headerLines[$header] = $this->headers[$name];
        }

        return $this;
    }
375419
public function addHeader(string $header, string $value): self
    {
        $this->headers[$header] = $value;

        return $this;
    }
801077
public function filter($value)
    {
        if (!$value instanceof User) {
            return array();
        }

        $info = $value->getInfo();

        return array(
            'id' => $value->getId(),
            'name' => $info->displayName,
            'image' => $info->image ? $info->image->uri : '',
            'email' => $info->email,
        );
    }
1267486
public function addHeader ($header, $value = null)
		{
			if ($value)
				$this->_headers[] = "$header: $value";
			else
				$this->_headers[] = $header;

			return $this;
		}
1363766
protected function serialize($value)
    {
        if (!is_array($value)) {
            return $value;
        }
        return Serialize::serialize($value, $this->serializer);
    }