Perform a GET request.

@param string $url     Request URL
@param array  $params  Request parameters
@param float  $timeout Request timeout in seconds
@param array  $headers Request headers

@return \Zend\Http\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);
    }
1154518
public function doRequest($type, $url, $params, $options = [], $headers = []) {
        // get access to the curl wrapper and set the bearer
        $curl = CURL::setBearer($this->getAccessToken());

        // set the request options
        foreach ($options as $var => $value) {
            $curl->setOption($var, $value);
        }

        // set the header values
        foreach ($headers as $var => $value) {
            $curl->setHeader($var, $value);
        }

        // execute the request
        $result = $curl->$type($url, $params);

        // done, return the result
        return $result;
    }
1057459
public function get($api, $params = [], $timeout = null) {
        $this->prepare($params, $api);
        $url = $this->url . '?' . http_build_query($params);
        curl_setopt($this->curl, CURLOPT_URL, $url);
        curl_setopt($this->curl, CURLOPT_HTTPGET, 1);
        curl_setopt($this->curl, CURLOPT_UPLOAD, false);
        if (is_numeric($timeout) && $timeout) {
            $this->timeout = $timeout;
            curl_setopt($this->curl, CURLOPT_TIMEOUT, $timeout);
        }

        return $this;
    }
1140209
public static function http_get($url, $timeOut = 5, $connectTimeOut = 5) {
		$oCurl = curl_init ();
		if (stripos ( $url, "http://" ) !== FALSE || stripos ( $url, "https://" ) !== FALSE) {
			curl_setopt ( $oCurl, CURLOPT_SSL_VERIFYPEER, FALSE );
			curl_setopt ( $oCurl, CURLOPT_SSL_VERIFYHOST, FALSE );
		}
		curl_setopt($oCurl, CURLOPT_URL, $url );
		curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
		curl_setopt($oCurl, CURLOPT_TIMEOUT, $timeOut);
        curl_setopt($oCurl, CURLOPT_CONNECTTIMEOUT, $connectTimeOut);
		$sContent = curl_exec ( $oCurl );
		$aStatus = curl_getinfo ( $oCurl );
        $error = curl_error( $oCurl );
		curl_close ( $oCurl );
		if (intval ( $aStatus ["http_code"] ) == 200) {
			return array(
					'status' => true,
					'content' => $sContent,
					'code' => $aStatus ["http_code"],
			);
		} else {
			return array(
					'status' => false,
					'content' => json_encode(array("error" => $error, "url" => $url)),
					'code' => $aStatus ["http_code"],
			);
		}
	}
788497
protected function request($url, $options = array(), $acceptheader = 'application/json') {
        $murl = new moodle_url($url);

        if ($this->accesstoken) {
            if ($this->use_http_get()) {
                // If using HTTP GET add as a parameter.
                $murl->param('access_token', $this->accesstoken->token);
            } else {
                $this->setHeader('Authorization: Bearer '.$this->accesstoken->token);
            }
        }

        if ($acceptheader) {
            $this->setHeader('Accept: ' . $acceptheader);
        }

        $response = parent::request($murl->out(false), $options);

        $this->resetHeader();

        return $response;
    }
1213987
public function get($url, array $urlParameters = [], array $headers = [], $asJSON = false)
    {
        $request = $this->prepareRequest($url, $urlParameters, $headers);

        return $this->executeRequest($request);
    }
248729
public function get($url, $params = [], $options = [], $headers = []) {
        return $this->makeCall('get', $url, $params, $options, $headers);
    }
652819
public static function head($url, $headers = array(), $options = array()) {
		return self::request($url, $headers, null, self::HEAD, $options);
	}
1095859
public static function PostRequest ($url, $post_data = [], $timeout = 30, $protocol_version = self::VERSION_1_1, $options = []) {
		$parsed_url = parse_url($url);

		$host = $parsed_url['host'];
		if (!isset($parsed_url['port'])) {
			$port = $parsed_url['scheme'] === 'https' ? 443 : 80;
		}
		$path = $parsed_url['path'];

		$request_headers = [
			sprintf('POST %s HTTP/%s', $path, $protocol_version),
			sprintf('Host: %s', $host),
			'User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)',
			'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
			'Accept-Language: ja,en-us;q=0.7,en;q=0.3',
			'Accept-Encoding: gzip, deflate',
			'Connection: keep-alive',
			'Content-Type: application/x-www-form-urlencoded',
		];

		$enable_send_data = !empty($post_data);
		if ($enable_send_data) {
			$raw_post_data = http_build_query($post_data);
			$raw_post_data_length = strlen($raw_post_data);
			$request_headers[] = sprintf('Content-Length: %d', $raw_post_data_length);
		}
		if (isset($options['basic']) && is_array($options['basic'])) {
			$request_headers[] = sprintf('Authorization: Basic %s', base64_encode(implode(':', $options['basic'])));
		}

		$request_header = implode("\r\n", $request_headers) . "\r\n\r\n";

		$request = $enable_send_data ? sprintf("%s%s", $request_header, $raw_post_data) : $request_header;
		$request .= "\r\n\r\n";

		$schema = $parsed_url['scheme'] === 'https' ? 'ssl://' : '';

$data = http_build_query($post_data);

$header = array(
	'Content-Type: application/x-www-form-urlencoded',
	'Content-Length: '.strlen($data),
	'Authorization: Basic '.base64_encode('a:a'),
);

$context = array(
	'http' => array(
		'method'	=> 'POST',
		'header'	=> implode("\r\n", $header),
		'content'	=> $data,
	),
);

echo file_get_contents($url, false, stream_context_create($context));

		/*
		$fp = fsockopen($schema . $host, $port, $errno, $errstr, $timeout);
		if (!$fp) {
			CoreException::ScrubbedThrow(Status::SystemError(sprintf('%s (%s)', $errstr, $errno)));
		}

		fwrite($fp, $request_header);

		$return_data = [];
		$start_mts = microtime(true);
		while (!feof($fp) && (microtime(true) - $start_mts) < $timeout) {
			$return_data[] = trim(fgets($fp, 4000));
		}
		fclose($fp);

		$response_header = [];
		$response_body = [];
		$in_header = true;
		foreach ($return_data as $row) {
			if ($in_header && trim($row) === "") {
				$in_header = false;
				continue;
			}
			if ($in_header) {
				if (preg_match("/^HTTP\/(\d+.\d+) (\d+) (.+)$/", $row, $matches) === 1) {
					$response_header['http'] = [
						'version'	=> $matches[1],
						'status'	=> [
							'code'		=> $matches[2],
							'message'	=> $matches[3],
						],
					];
					continue;
				}
				if (preg_match("/^([^:]+): (.+)/", $row, $matches) === 1) {
					$response_header[$matches[1]] = $matches[2];
					continue;
				}
			} else {
				$response_body[] = $row;
			}
		}
		return [
			'header'	=> $response_header,
			'body'		=> $response_body,
		];
		*/
	}
1318729
public function get($url, array $data = [], array $headers = [], $cacheMinutes = 0, HttpExceptionHandler $handler = null)
    {
        return $this->send('get', $url, $data, $headers, $cacheMinutes, $handler);
    }
531009
public static function get($url, $httpHeaders = array())
    {
        self::prepareRequest($httpHeaders);

        $response = CurlRequest::get($url, self::$httpHeaders);

        return self::processResponse($response);
    }
826401
public static function create(string $baseUrl, array $headers = [], $timeout = 30, bool $allowRedirects = false): Client
    {
        return new Client([
            'base_uri' => $baseUrl,
            'headers'  => $headers,
            'timeout'  => $timeout,
            'allow_redirects' => $allowRedirects,
        ]);
    }
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;
    }
1020142
public function goSinglePost($url = '', $data = [], $timeout = 30000, $headers = [])
    {
        if (empty($data)) {
            throw new Exception('post data is empty');
        }

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

        yield $this->goDnsLookup();
        $this->setHeaders($headers);

        if (!empty($this->urlData['query'])) {
            return yield $this->getObject(
                Http::class,
                [$this, 'POST', $this->urlData['path'] . $this->urlData['query'], $data, $timeout]
            );
        } else {
            return yield $this->getObject(
                Http::class,
                [$this, 'POST', $this->urlData['path'], $data, $timeout]
            );
        }
    }
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;
    }
780557
public static function connect($url, $headers = [], $parameters = null)
    {
        return Request::create('default')->connect($url, $headers, $parameters);
    }
240303
public function get($url, $headers = [], $options = [])
    {
        return $this->request('GET', $url, null, $headers, $options);
    }