cURL request

@param array $options
@return bool
6106
private function request($options = [])
    {
        $curl = curl_init();
        $caPathOrFile = CaBundle::getSystemCaRootBundlePath();
        // Set default cURL options
        curl_setopt_array($curl, [
            CURLOPT_AUTOREFERER => true,
            CURLOPT_CONNECTTIMEOUT => 30,
            CURLOPT_ENCODING => 'identity',
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_NONE,
            CURLOPT_IPRESOLVE => CURL_IPRESOLVE_WHATEVER,
            CURLOPT_SSL_VERIFYHOST => 2,
            CURLOPT_SSL_VERIFYPEER => true,
            CURLOPT_TIMEOUT => 120,
            CURLOPT_USERAGENT => self::CURL_USER_AGENT,
            (is_dir($caPathOrFile) ||
                (
                    is_link($caPathOrFile) &&
                    is_dir(readlink($caPathOrFile))
                )
            ) ? CURLOPT_CAPATH : CURLOPT_CAINFO => $caPathOrFile
        ]);
        if (PHP_VERSION_ID >= 70700) {
            curl_setopt($curl, CURLOPT_SSL_VERIFYSTATUS, true);
        }
        // Apply custom cURL options
        curl_setopt_array($curl, $options);
        // Initialize the header parser
        $this->headerParser = new Parser\HeaderParser($curl);
        // Make sure these cURL options stays untouched
        curl_setopt_array($curl, [
            CURLOPT_FAILONERROR => false,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_FTPSSLAUTH => CURLFTPAUTH_DEFAULT,
            CURLOPT_HEADER => false,
            CURLOPT_HEADERFUNCTION => [$this->headerParser, 'curlCallback'],
            CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
            CURLOPT_MAXREDIRS => self::MAX_REDIRECTS,
            CURLOPT_NOBODY => false,
            CURLOPT_PROTOCOLS => CURLPROTO_FTP | CURLPROTO_FTPS | CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_SFTP,
            CURLOPT_REDIR_PROTOCOLS => CURLPROTO_FTP | CURLPROTO_FTPS | CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_SFTP,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_URL => $this->base . self::PATH,
            CURLOPT_USERPWD => 'anonymous:anonymous@',
        ]);
        // Execute cURL request
        if (($this->rawContents = curl_exec($curl)) === false) {
            // Request failed
            return false;
        }
        $this->time = time();
        $this->rawStatusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); // also works with FTP status codes
        $uriParser = new UriParser(curl_getinfo($curl, CURLINFO_EFFECTIVE_URL));
        $this->effective = $uriParser->base();
        curl_close($curl);
        $this->rawEncoding = $this->headerParser->getCharset();
        $this->rawMaxAge = $this->headerParser->getMaxAge();
        return true;
    }
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;
    }
700168
public function curlPost($url, array $params = [], array $opts = [])
    {
        $options = [
            CURLOPT_POST    => true,
            CURLOPT_URL     => $url,
        ];
        foreach ($opts as $key => $value) {
            if ($key !== CURLOPT_POST && $key !== CURLOPT_URL) {
                $options[$key] = $value;
            }
        }
        if (!array_key_exists(CURLOPT_POSTFIELDS, $options)) {
            $options[CURLOPT_POSTFIELDS] = $this->params($params);
        }

        return self::curl($options);
    }
1072409
protected function callHttp(array $options)
    {
        $options += [
            'method' => 'post',
            'dataType' => 'json',
            'throwException' => false,
        ];
        $options['url'] = $this->baseUrl . $options['url'];
        $options['data'] = json_encode($options['data'], JSON_UNESCAPED_UNICODE);

        $http = $this->http($options);

        return $this->parseResponse($http, $options);
    }
923531
public function httpGet($url, array $options = [])
    {
        \Yii::info([
            'url' => $url,
            'options' => $options
        ], __METHOD__);
        return $this->parseHttpRequest(function($url) {
            return $this->http($url);
        }, $this->httpBuildQuery($url, $options));
    }
244938
protected function execute_curl($options) {
		$ch = curl_init();
		curl_setopt_array($ch, $options);
		$returned = curl_exec($ch);
		$response = HttpClientResponse::instance_from_curl($ch, $returned);
		curl_close($ch);
		return $response;
	}
282317
public function getGroupList($options=array()){

        $data = array();
        

        $data = array_merge($data, $options);

        return $this->request($this->groupGetlistUrl, $data);
    }
148071
protected function exec(array $options = [])
    {
        // cURL init and options
        $curl = curl_init();

        // we avoid curl_setopt_array($curl, $options) because extrange Windows behaviour (issue #8)
        foreach($options as $option => $value)
        {
            curl_setopt($curl, $option, $value);
        }

        // make the request
        if(is_null($this->callback))
        {
            $this->response = curl_exec($curl);
        }
        else
        {
            $this->response = '';
            curl_exec($curl);
        }

        // exception if cURL fails
        if(curl_errno($curl))
        {
            throw new Exception(curl_error($curl), curl_errno($curl));
        }

        // return the response and the status code
        return [trim($this->response), curl_getinfo($curl, CURLINFO_HTTP_CODE)];
    }
905129
public static function get(string $url, array $options = []) : array {
		$result = [
			'success' => false,
			'error' => [],
			'data' => null
		];
		if (strpos($url, '?') !== false) {
			$url.= '&';
		} else {
			$url.= '?';
		}
		$url.= http_build_query2($options['params']);
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$result['data'] = curl_exec($ch);
		if (!empty($options['json'])) {
			$result['data'] = json_decode($result['data'], true);
		}
		curl_close($ch);
		$result['success'] = true;
		return $result;
	}
789591
public function sendRequest(array $options = [])
    {
        $this->autoInitialize();

        if ( ! empty($options))
        {
            if ( ! $this->setOptions($options))
            {
                return false;
            }
        }

        $this->response = curl_exec($this->curl);

        return $this->response;
    }
814303
private function simpleGet($url, array $options = [])
    {
        return (array) \GuzzleHttp\json_decode(
          $this->getConnector()
               ->getClient()
               ->request('get', $url, $options)
               ->getBody()
               ->getContents(),
          true
        );
    }
1025859
protected function exec(Url $url, array $options)
    {
        $connection = curl_init((string) $url);
        curl_setopt_array($connection, $options);

        $curl = new CurlResult($connection);

        //Get only text responses
        $curl->onHeader(function ($name, $value, $data) {
            if ($name === 'content-type') {
                $data->isBinary = !preg_match('/(text|html|json)/', strtolower($value));
            }
        });

        $curl->onBody(function ($string, stdClass $data) {
            return empty($data->isBinary);
        });

        curl_exec($connection);

        $result = $curl->getResult();

        curl_close($connection);

        return $this->responses[] = new Response(
            $url,
            Url::create($result['url']),
            $result['statusCode'],
            $result['contentType'],
            $result['content'],
            $result['headers'],
            $result['info']
        );
    }
177178
public static function post(string $url, array $options = []) : array {
		$result = [
			'success' => false,
			'error' => [],
			'data' => null
		];
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query2($options['params']));
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$result['data'] = curl_exec($ch);
		if (!empty($options['json'])) {
			$result['data'] = json_decode($result['data'], true);
		}
		curl_close($ch);
		$result['success'] = true;
		return $result;
	}
53409
public function head($url, $options = array()) {
        $options['CURLOPT_HTTPGET'] = 0;
        $options['CURLOPT_HEADER']  = 1;
        $options['CURLOPT_NOBODY']  = 1;
        return $this->request($url, $options);
    }
1261150
public function trace($url, $options = array()) {
        $options['CURLOPT_CUSTOMREQUEST'] = 'TRACE';
        $ret = $this->request($url, $options);
        return $ret;
    }
237743
public function listBucketsRequest($options=array())
    {
        $operation = array(
            'API' => 'ListBuckets',
            'Method' => 'GET',
            'Uri' => '/',
            'Headers' => array(
                'Host' => $this->config->host,
                'Location' => isset($options['Location'])?$options['Location']:null,
            ),
            'Params' => array(
            ),
            'Elements' => array(
            ),
            'Properties' => array(),
            'Body' => null
        );
        $this->listBucketsValidate($operation);
        $req = new Request($this->config, $operation);
        return $req;
    }
146904
public function setCurlOptions(array $options) {
        return new Request([
            'method'              => $this->method,
            'url'                 => $this->url,
            'curlOptions'         => $options,
            'query'               => $this->query,
            'payload'             => $this->payload,
            'expectedStatusCodes' => $this->expectedStatusCodes
        ]);
    }