获取返回的错误信息

@param string $header_string

@return mixed
970930
private function _getErrorMessage($header_string) {
        list($status, $stash) = explode("\r\n", $header_string, 2);
        list($v, $code, $message) = explode(" ", $status, 3);
        return $message . " X-Request-Id: " . $this->getXRequestId();
    }
906826
protected function call($request, $header)
    {
        if (empty($request['call']))
        {
            return array('errno' => self::ERR_PARAMS);
        }
        /**
         * 侦测服务器是否存活
         */
        if ($request['call'] === 'PING')
        {
            return array('errno' => 0, 'data' => 'PONG');
        }
        //验证客户端IP是否被允许访问
        if ($this->verifyIp)
        {
            if (!$this->verifyIp(self::$clientEnv['_socket']['remote_ip']))
            {
                return array('errno' => self::ERR_ACCESS_DENY);
            }
        }
        //验证密码是否正确
        if ($this->verifyUser)
        {
            if (empty(self::$clientEnv['user']) or empty(self::$clientEnv['password']))
            {
                fail:
                return array('errno' => self::ERR_USER);
            }
            if (!$this->verifyUser(self::$clientEnv['user'], self::$clientEnv['password']))
            {
                goto fail;
            }
        }
        //函数不存在
        if (!is_callable($request['call']))
        {
            return array('errno' => self::ERR_NOFUNC);
        }
        //前置方法
        if (method_exists($this, 'beforeRequest'))
        {
            $this->beforeRequest($request);
        }
        //调用接口方法
        $ret = call_user_func_array($request['call'], $request['params']);
        //后置方法
        if (method_exists($this, 'afterRequest'))
        {
            $this->afterRequest($ret);
        }
        //禁止接口返回NULL，客户端得到NULL时认为RPC调用失败
        if ($ret === NULL)
        {
            return array('errno' => self::ERR_CALL);
        }
        return array('errno' => 0, 'data' => $ret);
    }
592544
public static function phpPost($url, $post_data = [], $timeout = 5, $header = "", $data_type = "")
    {
        $header = empty($header) ? self::defaultHeader() : $header;
        //支持json数据数据提交
        if ($data_type == 'json') {
            $post_string = json_encode($post_data);
        } else if (is_array($post_data)) {
            $post_string = http_build_query($post_data, '', '&');
        } else {
            $post_string = $post_data;
        }
        $header .= "Content-length: " . strlen($post_string);
        $opts = [
            'http' => [
                'protocol_version' => '1.0', //http协议版本(若不指定php5.2系默认为http1.0)
                'method' => "POST", //获取方式
                'timeout' => $timeout, //超时时间
                'header' => $header,
                'content' => $post_string
            ]
        ];
        $context = stream_context_create($opts);
        return @file_get_contents($url, false, $context);
    }
532536
public function streaming_header_callback($curl_handle, $header_content)
   {
        $code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);

        if (isset($this->write_file) && intval($code) / 100 == 2 && !isset($this->write_file_handle))
        {
            $this->write_file_handle = fopen($this->write_file, 'w');
            $this->set_write_stream($this->write_file_handle);
        }

        $this->response_raw_headers .= $header_content;
        return strlen($header_content); 
    }
1119108
protected function headerLine(/** @noinspection PhpUnusedParameterInspection */$curl, $header_line){
		$header = explode(':', $header_line, 2);

		if(count($header) === 2){
			$this->response_headers->{trim(strtolower($header[0]))} = trim($header[1]);
		}
		elseif(substr($header_line, 0, 4) === 'HTTP'){
			$status = explode(' ', $header_line, 3);

			$this->response_headers->httpversion = explode('/', $status[0], 2)[1];
			$this->response_headers->statuscode  = intval($status[1]);
			$this->response_headers->statustext  = trim($status[2]);
		}

		return strlen($header_line);
	}
735138
protected function findRedirectLinkInHeader(&$http_header)
  {
    PHPCrawlerBenchmark::start("checking_for_redirect_link");
    
    // Get redirect-URL or link from header
    $redirect_link = PHPCrawlerUtils::getRedirectURLFromHeader($http_header);
    
    // Add redirect-URL to linkcache
    if ($redirect_link != null)
    {
      $this->addLinkToCache($redirect_link, "", "", true);
    }
    
    PHPCrawlerBenchmark::stop("checking_for_redirect_link");
  }
215185
public static function parseHeader(string $raw_header): array
    {
        static $whole_fields = [
            'date' => true,
            'user-agent' => true,
        ];

        /**
         * 生成供于遍历的的header数组 ['row','row','row']
         */
        // Pretend CRLF = LF for compatibility (RFC 2616, section 19.3)
        $raw_header = str_replace("\r\n", "\n", $raw_header);
        // Unfold headers (replace [CRLF] 1*( SP | HT ) with SP) as per RFC 2616 (section 2.2)
        $raw_header = preg_replace('/\n[ \t]/', ' ', $raw_header);
        $header = [];
        $raw_header = preg_replace_callback('/(?:.*)HTTP\/[\d.]+(?: (\d+) [\w -]+)?\n/i',
            function (array $match) use (&$header) {
                if (!empty($match[1])) {
                    $header['status'] = [(int)$match[1]];
                }
                return '';
            }, $raw_header);
        $raw_header = explode("\n", $raw_header);

        /**
         * 生成可用的header数组 ['key'=>['val'],'key'=>['val']，'key'=>['val']]
         */
        foreach ($raw_header as $row) {
            list($key, $value) = explode(':', $row, 2);
            $key = strtolower($key);
            if ($key === 'set-cookie') {
                $header[$key][] = self::trimHeaderValues($value);
            } else {
                $value = self::trimHeaderValues(
                    isset($whole_fields[$key]) ? [$value] : explode(",", $value)
                );
                $header[$key] = $value;
            }
        }

        return $header;
    }
7972
function getHeader($header)
    {
        if (! $this->hasHeader($header)) {
            if (strtolower($header) === 'host'
                && ($this->uri && $this->uri->getHost())
            )
                return array($this->_getHostFromUri());

            return array();
        }

        $header = $this->_c_headerNormalized[strtolower($header)];
        $value  = $this->headers[$header];
        $value  = is_array($value) ? $value : array($value);
        return $value;
    }
1335005
def get_header(self, header_name):
        
        if header_name in self.headers:
            return self.headers[header_name]
        return self.add_header_name(header_name)
327447
public static function getHeaderInfo($header = '', $echo = true)
    {
        ob_start();
        $headers = getallheaders();
        if (!empty($header)) {
            $info = $headers[$header];
            echo($header . ':' . $info . "\n");;
        } else {
            foreach ($headers as $key => $val) {
                echo("$key:$val\n");
            }
        }
        $output = ob_get_clean();
        if ($echo) {
            echo(nl2br($output));
        } else {
            return $output;
        }
        return '';
    }
451851
protected function makeDataToSign($auth_header)
    {
        $query = '';
        if (isset($this->config['query']) && $this->config['query']) {
            $query .= '?';
            if (is_string($this->config['query'])) {
                $query .= $this->config['query'];
            } else {
                $query .= $this->buildQueryString($this->config['query']);
            }
        }

        $data = array(
            strtoupper($this->httpMethod),
            'https',
            $this->host,
            $this->path . $query,
            $this->canonicalizeHeaders(),
            (strtoupper($this->httpMethod) === 'POST') ? $this->makeContentHash() : '',
            $auth_header
        );

        return implode("\t", $data);
    }
525263
public function getPhpInfo()
    {
        ob_start();
        phpinfo();
        $pinfo = ob_get_contents();
        ob_end_clean();
        $phpinfo = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $pinfo);
        $phpinfo = str_replace('<table',
            '<div class="table-responsive"><table class="table table-condensed table-bordered table-striped table-hover config-php-info-table" ',
            $phpinfo);
        $phpinfo = str_replace('</table>', '</table></div>', $phpinfo);
        $phpinfo = str_replace('<div class="center">', '<div class="phpinfo">', $phpinfo);
        return $phpinfo;
    }
1127552
public static function parseStr($s, &$var, $header = false)
    {
        static $cb;
        if ($cb === null) {
            $cb = function ($m) {
                return urlencode(html_entity_decode('&#' . hexdec($m[1]) . ';', ENT_NOQUOTES, 'utf-8'));
            };
        }
        if ($header) {
            $s = strtr($s, Generic::$hvaltr);
        }
        if ((stripos($s, '%u') !== false)
            && preg_match('~(%u[a-f\d]{4}|%[c-f][a-f\d](?!%[89a-f][a-f\d]))~is', $s, $m)
        ) {
            $s = preg_replace_callback('~%(u[a-f\d]{4}|[a-f\d]{2})~i', $cb, $s);
        }
        parse_str($s, $var);
    }
661020
public function hscan($str_key, &$i_iterator, $str_pattern = null, $i_count = null)
    {
        return $this->xxxScan('hscan', $str_key, $i_iterator, $str_pattern, $i_count);
    }
625817
public function getHeaderStr()
    {
        $headers = [];
        foreach ($this->getHeaders() as $co => $vo) {
            foreach ($vo as $ko) {
                $headers[] = $co . ': ' . $ko;
            }
        }
        return $headers;
    }
1061815
public function read($cookie_name = null)
    {
        if (!empty($cookie_name)) {
            $this->setName($cookie_name);
        }
        $val = isset($_COOKIE[$this->getName()]) ? $_COOKIE[$this->getName()] : null;
        if ($val && is_string($val) && ($this->getFlag() & self::FLATNESS_ARRAY)) {
            parse_str($val, $tmp_val); 
            if (!empty($tmp_val) && $tmp_val!=$val) {
                $val = $tmp_val;
            }
        }
        $this->setValue($val);
        return $this->getValue();
    }
1016274
function getQueryString ( $oauth_as_header = true )
	{
		$parms = array();
		foreach ($this->param as $name => $value)
		{
			if (	!$oauth_as_header 
				||	(strncmp($name, 'oauth_', 6) != 0 && strncmp($name, 'xoauth_', 7) != 0))
			{
				if (is_array($value))
				{
					foreach ($value as $v)
					{
						$parms[] = $name.'='.$v;
					}
				}
				else
				{
					$parms[] = $name.'='.$value;
				}
			}
		}
		return implode('&', $parms);
	}