在完成DNS查询的基础上，运行GET请求协程

@param string $url 请求的URL
@param array $query POST的数据
@param int $timeout 请求超时时间
@param array $headers 额外的报头
@return Http
@throws Exception
434882
public function goGet($url = '', $query = null, $timeout = 30000, $headers = [])
    {
        if (!($this->client instanceof \swoole_http_client)) {
            throw new Exception('You must complete the DNS query first, Such as $client->goDnsLookup()');
        }

        if (empty($this->urlData)) {
            $this->urlData = self::parseUrl($url);
        } else {
            if (!empty($url)) {
                $this->urlData['path'] = $url;
            }
        }
        $this->setHeaders($headers);

        //支持直接在url之后带参数形式的GET请求
        $q = '';
        if (!empty($this->urlData['query'])) {
            $q = ltrim($this->urlData['query'], '?');
        }

        if (!empty($query)) {
            $q .= (empty($q) ? '' : '&') . http_build_query($query) ;
        }

        $sendGetReq  = $this->getObject(Http::class, [$this, 'GET', $this->urlData['path'], $q, $timeout]);

        return $sendGetReq;
    }
1166465
public static HttpRequestBase get(String path,
	                                  Map<String, String> headers,
	                                  Integer timeOutInSeconds) {


		HttpGet get = new HttpGet(path);
		addHeaders(get, headers);
		get.setConfig(getConfig(timeOutInSeconds));
		return get;
	}
1233984
public static function get($url, $query_data = null, array $headers = array(), array $options = array())
    {
        return self::request('GET', $url, $query_data, null, $headers, $options);
    }
253074
public function searchList($query, array $parameters = [], array $headers = [])
    {
        return $this->get('search/list', array_merge($parameters, [
            'query' => $query
        ], $headers));
    }
559335
private function httpRequest(
        $url,
        $request,
        $data = array(),
        $sendHeaders = array(),
        $timeout = 10
    ) {
        $streamParams = array(
            'http' => array(
                'method' => $request,
                'ignore_errors' => true,
                'timeout' => $timeout,
                'header' => "User-Agent: " . $this->userAgent . "\r\n"
            )
        );
        foreach ($sendHeaders as $header => $value) {
            $streamParams['http']['header'] .= $header . ': ' . $value . "\r\n";
        }
        foreach ($this->extraHeaders as $header => $value) {
            $streamParams['http']['header'] .= $header . ': ' . $value . "\r\n";
        }

        if (is_array($data)) {
            if (in_array($request, array('POST', 'PUT')))
                $streamParams['http']['content'] = http_build_query($data);
            elseif ($data && count($data))
                $url .= '?' . http_build_query($data);
        } elseif ($data !== null) {
            if (in_array($request, array('POST', 'PUT')))
                $streamParams['http']['content'] = $data;
        }

        $streamParams['cURL'] = $streamParams['http'];

        $context = stream_context_create($streamParams);
        $fp = @fopen($url, 'rb', false, $context);
        if (!$fp)
            $content = false;
        else
            $content = stream_get_contents($fp);

        $status = null;
        $statusCode = null;
        $headers = array();

        if ($content !== false) {
            $metadata = stream_get_meta_data($fp);
            if (isset($metadata['wrapper_data']['headers']))
                $headerMetadata = $metadata['wrapper_data']['headers'];
            else
                $headerMetadata = $metadata['wrapper_data'];
            foreach ($headerMetadata as $row) {
                if (preg_match('/^HTTP\/1\.[01] (\d{3})\s*(.*)/', $row, $m)) {
                    $statusCode = $m[1];
                    $status = $m[2];
                } elseif (preg_match('/^([^:]+):\s*(.*)$/', $row, $m)) {
                    $headers[mb_strtolower($m[1])] = $m[2];
                }
            }
        }

        return (object) array(
            'ok' => $statusCode == 200,
            'statusCode' => $statusCode,
            'status' => $status,
            'content' => $content,
            'headers' => $headers
        );
    }
830556
final public static function redirect(
        string $url,
        array $query = array(),
        bool $domain = true,
        int $status = 302
    ) {
        $newurl = $url;
        $iterator = 0;
        $domainstring = "";
        foreach ($query as $one => $value) {
            $newurl .= ((0 === $iterator)? "?" : "")."$one=$value".((count($query) === $iterator + 1)? "" : "&");
        }
        if (true === $domain) {
            $server = new GlobalServer();
            $https = ((null !== $server->get("HTTPS") &&
                "on" === $server->get("HTTPS"))? "https://" : "http://");
            $domainstring = $https.$server->get("HTTP_HOST");
        }

        if (isset($newurl[0]) && $newurl[0] !== "/") {
            $newurl = "/".$newurl;
        }
 
        header("Location: $domainstring$newurl", true, $status);
        exit(1);
    }
1300553
public static String get(String urlString, int timeout) {
		return HttpRequest.get(urlString).timeout(timeout).execute().body();
	}
556706
public function cache($query, array $params = null, $timeout = null)
    {
        $options = array_merge($this->cacheOptions, [
            "sql"     =>  $this,
            "query"   =>  $query,
            "params"  =>  $params,
        ]);

        if ($timeout) {
            $options["timeout"] = $timeout;
        }

        return new Cache($options);
    }
842065
protected function perform($method, $url, $body = array(), $query = array(), $headers = array())
    {

        // response data placeholders
        $response = null;
        $responseHeaders = array();

        $logger = $this->getLogger();

        // determine allowed methods
        $methodName = strtoupper($method);

        // query string processing
        $processedUrl = $this->prepareUrl($url, $query);

        try {

            $logger->debug('NEW REQUEST: ' . $methodName . ' ' . $processedUrl);

            if (!in_array($methodName, array(
                'GET', 'POST', 'PUT', 'DELETE', 'HEAD'
            ))
            ) {
                throw new \Exception('Method not supported', HttpException::METHOD_NOT_SUPPORTED);
            }

            // prepare request headers and fields
            $contextParams = array(
                'http' => array(
                    'method' => $methodName,
                    'ignore_errors' => true   // we want to catch output although the error
                ));

            // skip SSL verification
            if($this->skipSsl){
                $contextParams['ssl'] = array(
                    'verify_peer'=>false,
                    'verify_peer_name'=>false
                );
            }

            // inject request parameters
            $this->applyHeaders($contextParams, $headers);
            $json = !empty($headers['Content-Type']) && $headers['Content-Type']=='application/json';
            $this->applyBody($contextParams, $methodName, $body, $json);

            // make request stream context
            $ctx = stream_context_create($contextParams);

            // initialize requests counter
            $counter = self::$retryLimit;

            $response = null;

            // perform request regarding counter limit and quotas
            while ($counter--) {
                try {
                    // pause upon limits exceeding
                    if (isset($responseHeaders['X-Shop-Api-Calls'])) {

                        $calls = $responseHeaders['X-Shop-Api-Calls'];
                        $limit = $responseHeaders['X-Shop-Api-Limit'];

                        if ($limit - $calls == 0) {
                            sleep(1);
                        }
                    }

                    $response = $this->doRequest($processedUrl, $ctx, $responseHeaders, $methodName);

                    break;
                } catch (\Exception $ex) {
                    // server pauses request for X seconds
                    if (!empty($responseHeaders['Retry-After'])) {
                        if ($counter <= 0) {
                            throw new \Exception('Retries count exceeded', HttpException::QUOTA_EXCEEDED);
                        }
                        sleep($responseHeaders['Retry-After']);
                    } else {
                        // other error
                        throw $ex;
                    }
                }
            }

            $parsedPayload = null;
            if ($methodName != 'HEAD') {
                // try to decode response
                if ($responseHeaders['Content-Type'] == 'application/json') {
                    $parsedPayload = @json_decode($response, true);

                    if (!$parsedPayload && !is_array($parsedPayload)) {
                        throw new \Exception('Result is not a valid JSON', HttpException::MALFORMED_RESULT);
                    }

                } else {
                    $parsedPayload = $response;
                }

                $logger->debug('Response body (decoded): ' . var_export($parsedPayload, true));
            }
        }catch(\Exception $ex){

            $message = $ex->getMessage();

            $logger->error(
                $ex->getMessage(), compact('method', 'url', 'query', 'headers', 'body', 'responseHeaders', 'response')
            );

            if($ex instanceof HttpException){
                $response = $ex->getResponse();
                $message = $ex->getMessage();
            }

            throw new HttpException(
                $message, $ex->getCode(), null, $method, $url, $headers, $query, $body, $response, $responseHeaders
            );
        }

        return array(
            'data' => $parsedPayload,
            'headers' => $responseHeaders
        );
    }
820434
public static function phpGet($url, $timeout = 5, $header = "")
    {
        $header = empty($header) ? self::defaultHeader() : $header;
        $opts = [
            'http' => [
                'protocol_version' => '1.0', //http协议版本(若不指定php5.2系默认为http1.0)
                'method' => "GET", //获取方式
                'timeout' => $timeout, //超时时间
                'header' => $header
            ]
        ];
        $context = stream_context_create($opts);
        return @file_get_contents($url, false, $context);
    }
1098546
private function request($query, $variables, $headers)
    {

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $this->url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['query' => $query, 'variables' => $variables]));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge($headers, [
            "X-Token: {$this->token}",
            "Content-Type: application/json;charset=utf-8"
        ]));
        $output = curl_exec($ch);

        curl_close($ch);

        return $output;
    }
28957
public function goPost($url = '', $data = [], $timeout = 30000, $headers = [])
    {
        if (empty($data)) {
            throw new Exception('post data is empty');
        }

        if (!($this->client instanceof \swoole_http_client)) {
            throw new Exception('You must complete the DNS query first, Such as $client->goDnsLookup()');
        }

        if (empty($this->urlData)) {
            $this->urlData = self::parseUrl($url);
        } else {
            if (!empty($url)) {
                $this->urlData['path'] = $url;
            }
        }
        $this->setHeaders($headers);
        $sendPostReq  = $this->getObject(Http::class, [$this, 'POST', $this->urlData['path'], $data, $timeout]);

        return $sendPostReq;
    }
1094608
public static function socketGet($url, $timeout = 5, $header = "")
    {
        $header = empty($header) ? self::defaultHeader() : $header;
        $url2 = parse_url($url);
        $url2["path"] = isset($url2["path"]) ? $url2["path"] : "/";
        $url2["port"] = isset($url2["port"]) ? $url2["port"] : 80;
        $url2["query"] = isset($url2["query"]) ? "?" . $url2["query"] : "";
        $host_ip = @gethostbyname($url2["host"]);

        if (($fsock = fsockopen($host_ip, $url2['port'], $errno, $errstr, $timeout)) < 0) {
            return false;
        }
        $request = $url2["path"] . $url2["query"];
        $in = "GET " . $request . " HTTP/1.0\r\n";
        if (false === strpos($header, "Host:")) {
            $in .= "Host: " . $url2["host"] . "\r\n";
        }
        $in .= $header;
        $in .= "Connection: Close\r\n\r\n";

        if (!@fwrite($fsock, $in, strlen($in))) {
            @fclose($fsock);
            return false;
        }
        return self::GetHttpContent($fsock);
    }
912639
public static HttpResponse doGetResponse(String host, String path,
                                             Map<String, String> headers,
                                             Map<String, String> queries) throws Exception {
        HttpClient httpClient = wrapClient(host);
        if (queries == null)
            queries = new HashMap<>();

        HttpGet request = new HttpGet(buildUrl(host, path, queries));

        if (headers == null) {
            headers = new HashMap<>();
            setHttpHeader(request);
        }

        for (Map.Entry<String, String> e : headers.entrySet()) {
            request.addHeader(e.getKey(), e.getValue());
        }
        return httpClient.execute(request);
    }
693365
protected function sendRequest($method, $url, array $params = [], array $headers = [])
    {
        $response = $request = $this->getHttpClient()->createRequest()
            ->setUrl($url)
            ->setMethod($method)
            ->setHeaders($headers)
            ->setData($params)
            ->send();
        if (!$response->isOk && $this->debug) {
            throw new Exception ('Http request failed.');
        }
        return $response;
    }
496426
public function get($url, array $params = [], $timeout = null,
        array $headers = []
    ) {
        if ($params) {
            $query = $this->createQueryString($params);
            if (strpos($url, '?') !== false) {
                $url .= '&' . $query;
            } else {
                $url .= '?' . $query;
            }
        }
        $client
            = $this->createClient($url, \Zend\Http\Request::METHOD_GET, $timeout);
        if ($headers) {
            $client->setHeaders($headers);
        }
        return $this->send($client);
    }
569182
public static function get($url, array $params = [], array $headers = [])
    {
        if ($params) {
            $url .= (strpos($url, '?') ? '&' : '?') . http_build_query($params);
        }

        // $headers = [ 'Content-Type: application/json' ];

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        //伪造网页来源地址,伪造来自百度的表单提交
        // curl_setopt($ch, CURLOPT_REFERER, "http://www.baidu.com");

        return self::execute($ch);
    }