Options

@access public
@param  $url
@param  $data

@return string
557524
public function options($url, $data = array())
    {
        if (is_array($url)) {
            $data = $url;
            $url = $this->baseUrl;
        }
        $this->setURL($url, $data);
        $this->unsetHeader('Content-Length');
        $this->setOpt(CURLOPT_CUSTOMREQUEST, 'OPTIONS');
        return $this->exec();
    }
852986
public function provide($data = null, array $options = [])
    {
        $result = (string)$data;

        if (empty($result)) {
            return $result;
        }

        if (!isset($options['linkTarget'])) {
            $options['linkTarget'] = static::TARGET;
        }

        // Sanitize
        $result = filter_var($result, FILTER_SANITIZE_URL);
        if ($result === false) {
            // If you find a case where FILTER_SANITIZE_URL fails, add
            // a unit test to UrlRendererTest and remove annotations here.
            // @codeCoverageIgnoreStart
            throw new InvalidArgumentException("Failed to sanitize URL");
            // @codeCoverageIgnoreEnd
        }

        // Only link to URLs with schema, to avoid unpredictable behavior
        if (filter_var($result, FILTER_VALIDATE_URL) === false) {
            return $result;
        }

        $view = $this->config->getView();
        $result = $view->Html->link($result, $result, ['target' => $options['linkTarget']]);

        return $result;
    }
1354459
protected function _doRequest($method, $url, $data, $options)
    {
        $request = $this->_createRequest(
            $method,
            $url,
            $data,
            $options
        );

        return $this->send($request, $options);
    }
1144625
public function get($url, array $data = [], array $headers = [])
    {
        $url = $this->optionParser->parseUrl($url, $data);

        $this->unsetOption(CURLOPT_POST);

        $this->setOptions([
            CURLOPT_CUSTOMREQUEST => 'GET',
            CURLOPT_HTTPGET => true
        ]);

        return $this->send($url, [], $headers);
    }
938022
public function delete($url, $data = null, $headers = [], $options = [])
    {
        return $this->createRequestShortcut('DELETE', $url, $data, $headers, $options);
    }
1031889
public function buildGetRequestObject(string $url, array $data = null): Request
    {
        $requestOptions = [
            RequestOptions::QUERY => $data
        ];
        $options = $this->buildRequest(self::METHOD_GET, $url, $requestOptions);
        $headers = isset($options[self::OPTION_OPTIONS][RequestOptions::HEADERS]) ? $options[self::OPTION_OPTIONS][RequestOptions::HEADERS] : [];
        $body = isset($options[self::OPTION_OPTIONS][RequestOptions::BODY]) ? $options[self::OPTION_OPTIONS][RequestOptions::BODY] : null;
        $version = isset($options[self::OPTION_OPTIONS][RequestOptions::VERSION]) ? $options[self::OPTION_OPTIONS][RequestOptions::VERSION] : '1.1';
        return new Request($options[self::OPTION_METHOD], $options[self::OPTION_URL], $headers, $body, $version);
    }
578209
public function delete($url, $data = [])
    {
        $this->setOpt(CURLOPT_URL, $this->_buildURL($url, $data));
        $this->setOpt(CURLOPT_CUSTOMREQUEST, 'DELETE');

        return $this->exec();
    }
574886
public function get($url, $params = array(), $options = array())
    {
        $rst = $this->getRequest()->get($url, $params, $options);
        return $rst;
    }
781218
public function put($url, $data = [], array $options = [])
    {
        $options = $this->_mergeOptions($options);
        $url = $this->buildUrl($url, [], $options);

        return $this->_doRequest(Request::METHOD_PUT, $url, $data, $options);
    }
492451
public function options($url, $headers = [], $parameters = null)
    {
        return $this->send(Method::OPTIONS, $url, $parameters, $headers);
    }
579008
public function delete($url, $data = [], $headers = [], $curl_opts = []) {
        $curl_opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
        return $this->load($url, $data, $headers, $curl_opts);
    }
1242478
function(_url,_data){
            var _sep = _url.indexOf('?')<0?'?':'&',
                _data = _data||'';
            if (_u._$isObject(_data))
                _data = _u._$object2query(_data);
            if (!!_data) _url += _sep+_data;
            return _url;
        }
907991
public function get($url, array $data = [])
    {
        if (count($data) > 0) {
            $this->setopt(CURLOPT_URL, $url.'?'.http_build_query($data));
        } else {
            $this->setopt(CURLOPT_URL, $url);
        }
        $this->setopt(CURLOPT_HTTPGET, true);
        $this->_exec();
    }
1359480
public static function upload($urlOrOptions, array $data = []): Curl
    {

        $options = $urlOrOptions;

        if (is_string($options))
        {
            $options = ['url' => $urlOrOptions];
        }

        if (!isset($options['url']))
        {
            throw new Exceptions\Invalid('Param option `URL` not found!');
        }

        $url    = $options['url'];
        $method = $options['method'] ?? 'post';
        $headers = $options['headers'] ?? [];

        $data = Arr::map($data, function ($value) {

            if (\is_string($value) && Str::first($value) === '@')
            {
                return curl_file_create(Str::withoutFirst($value));
            }

            return $value;

        });

        $curl = new Curl();

        if (!empty($headers))
        {
            foreach ($headers as $key => $value)
            {
                $headers[$key] = $key . ': ' . implode(',', (array)$value);
            }

            $curl->setOpt(CURLOPT_HTTPHEADER, Arr::getValues($headers));
        }

        $curl->$method($url, $data);

        $response = JSON::decode($curl->response);

        if (JSON::errorNone())
        {
            $curl->response = $response;
        }

        return $curl;

    }
685044
public function put($url, $data = '$undefined')
    {
        if ($data === '$undefined') {
            $data = ($url instanceof Resource)
                ? $url->data()
                : null;
        }
        return $this->request('put', $url, $data);
    }
729364
public function post($url, $data = array())
    {
        $this->setOpt(CURLOPT_URL, $url);
        $this->preparePayload($data);
        $this->exec();
        return $this;
    }
331371
protected function appendUrlOptions($url, $options)
    {
        $options = array_only($options, [
            'welcome_msg',
            'timezone',
            'anonymous',
            'minimal'
        ]);

        $boolean_keys = ['minimal', 'anonymous'];
        foreach ($boolean_keys as $key) {
            if (isset($options[$key])) {
                $options[$key] = $this->booleanToString($options[$key]);
            } else {
                $options[$key] = 'true';
            }
        }

        return $url . '?' . http_build_query($options);
    }