HTTP OPTIONS method

@param $url
@param null $fields null
@param callable $callback null
763347
public function options($url, $fields = null, callable $callback = null)
    {
        $this->send($url, self::OPTIONS, $fields, $callback);
    }
442408
private function matchMethod($callbacks, $url)
    {
        // match a callback based on url pattern
        $methodData = false;
        $matchedParameters = false;

        // match method
        foreach ($callbacks as $pattern => $data) {
            if (($matchedParameters = $this->doesPatternMatch($pattern, $data, $url)) !== false) {
                $methodData = $data;
                break;
            } else if ($data['resourceNaming'] === false) {
                $matchedParameters = $this->tryMatchingOptionalParams($pattern, $data, $url);
                if ($matchedParameters) {
                    $methodData = $data;
                    break;
                }
            }
        }

        return [
            'methodData'        => $methodData,
            'matchedParameters' => $matchedParameters
        ];
    }
1282602
public function put($url, $params = array(), $options = array()) {
        $file = '';
        $fp = false;
        if (isset($params['file'])) {
            $file = $params['file'];
            if (is_file($file)) {
                $fp   = fopen($file, 'r');
                $size = filesize($file);
                $options['CURLOPT_PUT']        = 1;
                $options['CURLOPT_INFILESIZE'] = $size;
                $options['CURLOPT_INFILE']     = $fp;
            } else {
                return null;
            }
            if (!isset($this->options['CURLOPT_USERPWD'])) {
                $this->setopt(array('CURLOPT_USERPWD' => 'anonymous: noreply@moodle.org'));
            }
        } else {
            $options['CURLOPT_CUSTOMREQUEST'] = 'PUT';
            $options['CURLOPT_POSTFIELDS'] = $params;
        }

        $ret = $this->request($url, $options);
        if ($fp !== false) {
            fclose($fp);
        }
        return $ret;
    }
765658
public static function post2https($fields_arr, $url)
    {
        $fields_string = '';
        //url-ify the data for the POST
        foreach ($fields_arr as $key => $value) {
            $fields_string .= $key . '=' . $value . '&';
        }
        $fields_string = substr($fields_string, 0, -1);

        //open connection
        $ch = curl_init();

        //set the url, number of POST vars, POST data
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, count($fields_arr));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


        //execute post
        $res = curl_exec($ch);

        //close connection
        curl_close($ch);
        return $res;
    }
534125
function http($url, $method, $postfields=null, $headers=array())
    {
        $this->http_info = array();
        $ci = curl_init();
        /* Curl settings */
        curl_setopt($ci, CURLOPT_USERAGENT, self::USER_AGENT);
        curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, self::CONNECT_TIMEOUT);
        curl_setopt($ci, CURLOPT_TIMEOUT, self::REQUEST_TIMEOUT);
        curl_setopt($ci, CURLOPT_RETURNTRANSFER, true);

        // Set request headers if any
        if (is_array($headers) && !empty($headers)){
            $this->http_request_headers = $headers;
            curl_setopt($ci, CURLOPT_HTTPHEADER, $headers);
        }

        curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, self::SSL_VERIFY_PEER);
        curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
        curl_setopt($ci, CURLOPT_HEADER, false);

        // Make sure the post fields are string
        if (is_array($postfields) && !empty($postfields)) {
            $postfields = http_build_query($postfields);
        }

        switch ($method) {
            case 'POST':
                curl_setopt($ci, CURLOPT_POST, true);
                if (!empty($postfields)) {
                    $this->http_post = $postfields;
                    curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
                }
                break;
            case 'DELETE':
                curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
                if (!empty($postfields)) {
                    $url = "{$url}?{$postfields}";
                }
        }

        curl_setopt($ci, CURLOPT_URL, $url);
        $response = curl_exec($ci);
        $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
        $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
        $this->http_url = $url;
        curl_close($ci);

        return $response;
    }
487868
public static function options($url, $headers = [], $parameters = null)
    {
        return Request::create('default')->options($url, $headers, $parameters);
    }
8680
public function post($url, array $params = null, array $options = array())
	{
		return $this->request($url, 'POST', $params, $options);
	}
1324548
function soap_transport_http($url, $curl_options = NULL, $use_curl = false){
		parent::nusoap_base();
		$this->debug("ctor url=$url use_curl=$use_curl curl_options:");
		$this->appendDebug($this->varDump($curl_options));
		$this->setURL($url);
		if (is_array($curl_options)) {
			$this->ch_options = $curl_options;
		}
		$this->use_curl = $use_curl;
		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
		$this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
	}
1085119
public static function put($urls, $data = null, callable $callback = null)
    {
        return static::make('put', $urls, $data, $callback);
    }
685173
public function initialise($url = null)
    {
        $this->replaceOptions(
            array(
                CURLOPT_URL => $url,
                CURLOPT_RETURNTRANSFER => true
            )
        );

        $this->info = array();
    }
169333
function http($url, $post_data = null) {/*{{{*/
    $ch = curl_init();
    if (defined("CURL_CA_BUNDLE_PATH")) curl_setopt($ch, CURLOPT_CAINFO, CURL_CA_BUNDLE_PATH);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //////////////////////////////////////////////////
    ///// Set to 1 to verify Server's SSL Cert //////
    //////////////////////////////////////////////////
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    if (isset($post_data)) {
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    }

    $response = curl_exec($ch);
    $this->http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $this->last_api_call = $url;
    curl_close ($ch);

	/**
    echo "<pre>";
    echo $url . "\n";
    print_r(explode("&", $post_data)) . "\n";
    print_r($response) . "\n";
    echo "---\n</pre>";
	 */

    return $response;
  }
1062224
function(options, callback) {
    request({
      method: 'post',
      url: options.url,
      headers: {
        'Authorization': 'Bearer ' + access_token,
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      form: options.data
    },
    function(error, response, body) {
      callback(error, body);
    });
  }
1165300
public function send($url, $method = 'GET', $data = null, callable $callback = null)
    {
        $this->curl($url);
        $this->setDefaultOptions();

        if (is_array($this->options))
        {
            if (count($this->options) > 0)
            {
                foreach ($this->options as $key => $value)
                {
                    $this->setOption($key, $value);
                }
            }
        }

        if ($method !== self::GET)
        {
            $this->method($method);
        }

        if ($method === self::POST || $method === self::PUT || $method === self::DELETE)
        {
            $this->setOption(CURLOPT_POSTFIELDS, $data);
        }

        $response = $this->execute();

        if (!$response)
        {
            $this->error();
        }

        $this->getInfo();
        $this->close();

        if ( is_callable($callback) )
        {
            $callback($this->response, $this->info, $this->errors);
        }

        return $response;
    }
309497
public function jsonp($callback, $data = [], $status = 200, array $headers = [], $options = 0)
    {
        respondWith(response()->jsonp($callback, $data, $status, $headers, $options));
    }
1343432
public function get($url, $queries = null, callable $callback = null)
    {
        if ( is_array($queries) )
        {
            $queries = '?' . http_build_query($queries);
        }

        return $this->send($url . $queries, self::GET, [], $callback);
    }
83546
protected function generateCallback($url = [])
    {
        if (empty($url)) {
            $url = $this->authChoice->createClientUrl($this->client);
        } else {
            $url = Url::to($url);
        }
        if (strpos($url, '?') === false) {
            $url .= '?';
        } else {
            $url .= '&';
        }

        $callbackName = 'googleSignInCallback' . md5($this->id);
        $js = <<<JS
function $callbackName(authResult) {
    var urlParams = [];

    if (authResult['code']) {
        urlParams.push('code=' + encodeURIComponent(authResult['code']));
    } else if (authResult['error']) {
        if (authResult['error'] == 'immediate_failed') {
            return;
        }
        urlParams.push('error=' + encodeURIComponent(authResult['error']));
        urlParams.push('error_description=' + encodeURIComponent(authResult['error_description']));
    } else {
        for (var propName in authResult) {
            var propValue = authResult[propName];
            if (typeof propValue != 'object') {
                urlParams.push(encodeURIComponent(propName) + '=' + encodeURIComponent(propValue));
            }
        }
    }

    window.location = '$url' + urlParams.join('&');
}
JS;
        $this->view->registerJs($js, View::POS_END, __CLASS__ . '#' . $this->id);

        return $callbackName;
    }
310561
public function trace($url, $fields = null, callable $callback = null)
    {
        $this->send($url, self::TRACE, $fields, $callback);
    }