Send a Caliper Body to the correct URL using the key and secret

This is not yet a standard or production - it uses the Canvas
extension only.
515137
public static function caliperSend($caliperBody, $content_type='application/json', &$debug_log=false)
    {

        $caliperURL = LTIX::ltiRawParameter('custom_sub_canvas_xapi_url');
        if ( strlen($caliperURL) == 0 ) {
            if ( is_array($debug_log) ) $debug_log[] = array('custom_sub_canvas_xapi_url not found in launch data');
            return false;
        }

        $key_key = self::ltiParameter('key_key');
        $secret = self::decrypt_secret(self::ltiParameter('secret'));

        $retval = LTI::sendJSONBody("POST", $caliperBody, $content_type,
            $caliperURL, $key_key, $secret, $debug_log);
        return $retval;
    }
648648
function(source, callback) {
        var url = this.getSignedResourceUrl('POST', this.getImagesUrl()),
            isFile = isBrowser && source instanceof window.File,
            onComplete = callback.onComplete || callback,
            onProgress = callback.onProgress || null;

        request({
            method: 'POST',
            uri: url,
            body: source,
            headers: {
                'Accept': 'application/json',
                'User-Agent': 'imboclient-js',
                'Content-Length': isFile ? source.size : source.length
            },
            onComplete: function(err, res, body) {
                body = jsonparse(body);
                onComplete(err, body ? body.imageIdentifier : null, body, res);
            },
            onProgress: onProgress
        });

        return this;
    }
76007
function handle_checkUrl(result)
			{
				maybeCallback(thisObj.handlers.link)(result, input.data.customData);
				
				// Auto-starts next queue item, if any
				// If not, fires "end"
				done();
			}
766839
def _req(self, endpoint, get_data=dict(), post_data=dict()):

        

        if get_data:
            request_parameter = "{}?{}".format(endpoint, urlencode(get_data))
        else:
            request_parameter = endpoint

        try:
            encdata = urlencode(post_data, True).encode('utf-8')
            response = self.oauth.request(request_parameter, data=encdata)
            self._checkResponseForErrors(response)
        except HTTPError as e:
            raise DeviantartError(e)

        return response
88524
def _send_mfg_inspector_request(envelope_data, credentials, destination_url):
  """"""
  logging.info('Uploading result...')
  http = httplib2.Http()

  if credentials.access_token_expired:
    credentials.refresh(http)
  credentials.authorize(http)

  resp, content = http.request(destination_url, 'POST', envelope_data)

  try:
    result = json.loads(content)
  except Exception:
    logging.debug('Upload failed with response %s: %s', resp, content)
    raise UploadFailedError(resp, content)

  if resp.status != 200:
    logging.debug('Upload failed: %s', result)
    raise UploadFailedError(result['error'], result)

  return result
135574
function setURLParameter(url, key, value) {
  if(typeof url !== 'string') {
    throw new Error('URLs must be a string');
  }

  if(urlUtils) {
    //node.js
    url = urlUtils.parse(url);

    url.search = ((url.search) ? url.search + '&' : '?') + key + '=' + value;

    url = urlUtils.format(url);
  }
  else {
    //browser
    url = url.split('?');

    url[1] = ((url[1]) ? url[1] + '&' : '') + key + '=' + value;

    url = url.join('?');
  }

  return url;
}
1133728
def create(key_body)
      client.ensure_master_key!

      path = ""
      response = access_keys_post(client.master_key, path, key_body)
      client.process_response(response.code.to_i, response.body)
    end
1128855
function URLGET(url, fields, method, callback)
	{
		// method variable is optional
		if (typeof method == "function")
		{
			callback = method;
			method = "GET";
		}

		_URLGET(url, fields, GetHeaders({"Access-Control-Request-Method": method}), method, function(err, body) {
			if (err)
			{
				// got error, bounce it up
				if (callback) callback(err);
				return;
			}
			else
			{
				var JSONBody;
				if (typeof body == "object")
				{
					// already a JSON object?
					JSONBody = body;
				}
				else
				{
					// try to parse JSON body
					if (!body || !/\S/.test(body))
					{
						// string is empty, return empty object
						if (callback) callback(false, {});
						return;
					}
					else
					{
						try
						{
							JSONBody = JSON.parse(body);
						}
						catch(parse_err)
						{
							// error parsing JSON result
							Log("Parse JSON error: " + parse_err + "\r\nURL:\r\n" + url + "\r\nBody:\r\n" + body);
							if (callback) callback("Parse JSON error: " + parse_err);
							return;
						}
					}
				}

				// success! return JSON object
				if (callback) callback(false, JSONBody);
			}
		});
	}
68178
function Verifier(givenMasterKey) {
  var masterKey = givenMasterKey || MASTER_KEY;
  if (!masterKey) {
    throw new errors.ValidationFailed('invalid master key');
  }
  this.masterKey = base64url.toBuffer(masterKey);
}
1191466
function (cb) {
					if (o1.options.tempURLKey) {
						o1._log('Setting temporary URL key for account...');
						o1._client.setTemporaryUrlKey(o1.options.tempURLKey, cb);
					} else {
						cb();
					}
				}
1017650
def url(self, key):
        
        return urlunparse((self.protocol, '%s:%s' % (self.domain, self.port),
                           '%s/api/v1%s' % (self.prefix, URLS[key]),
                           '', '', ''))
672632
def submit_url(self, url, params={}, _extra_params={}):
        
        self._check_user_parameters(params)
        params = copy.copy(params)
        params['url'] = url
        return self._submit(params, _extra_params=_extra_params)
94814
function(obj, methodName, methodArgs, probeData) {
        // Start metrics
        that.metricsProbeStart(probeData);
        that.requestProbeStart(probeData);
        // End metrics
        aspect.aroundCallback(
          methodArgs,
          probeData,
          function(target, args, probeData) {
            // Get HTTP request method from options
            var ri = getRequestItems(methodArgs[0]);
            that.metricsProbeEnd(probeData, ri.requestMethod, ri.urlRequested, args[0], ri.headers);
            that.requestProbeEnd(probeData, ri.requestMethod, ri.urlRequested, args[0], ri.headers);
          },
          function(target, args, probeData, ret) {
            // Don't need to do anything after the callback
            return ret;
          }
        );
      }
87234
def touch(self, pathobj):
        
        if not pathobj.drive or not pathobj.root:
            raise RuntimeError('Full path required')

        if pathobj.exists():
            return

        url = str(pathobj)
        text, code = self.rest_put(url, session=pathobj.session, verify=pathobj.verify, cert=pathobj.cert)

        if not code == 201:
            raise RuntimeError("%s %d" % (text, code))
1022444
def urlopen(self, method, url, body=None, headers=None, **kwargs):
        """"""
        # pylint: disable=arguments-differ
        # We use kwargs to collect additional args that we don't need to
        # introspect here. However, we do explicitly collect the two
        # positional arguments.

        # Use a kwarg for this instead of an attribute to maintain
        # thread-safety.
        _credential_refresh_attempt = kwargs.pop(
            '_credential_refresh_attempt', 0)

        if headers is None:
            headers = self.headers

        # Make a copy of the headers. They will be modified by the credentials
        # and we want to pass the original headers if we recurse.
        request_headers = headers.copy()

        self.credentials.before_request(
            self._request, method, url, request_headers)

        response = self.http.urlopen(
            method, url, body=body, headers=request_headers, **kwargs)

        # If the response indicated that the credentials needed to be
        # refreshed, then refresh the credentials and re-attempt the
        # request.
        # A stored token may expire between the time it is retrieved and
        # the time the request is made, so we may need to try twice.
        # The reason urllib3's retries aren't used is because they
        # don't allow you to modify the request headers. :/
        if (response.status in self._refresh_status_codes
                and _credential_refresh_attempt < self._max_refresh_attempts):

            _LOGGER.info(
                'Refreshing credentials due to a %s response. Attempt %s/%s.',
                response.status, _credential_refresh_attempt + 1,
                self._max_refresh_attempts)

            self.credentials.refresh(self._request)

            # Recurse. Pass in the original headers, not our modified set.
            return self.urlopen(
                method, url, body=body, headers=headers,
                _credential_refresh_attempt=_credential_refresh_attempt + 1,
                **kwargs)

        return response
180681
def _make_the_call(self, method, url, body=None):
        """"""
        self.log.debug("%s call to %s with body = %s" % (method, url, body))
        params = {"url": url, "headers": self.headers, "verify": self.verify}
        if body is not None:
            params["data"] = body
        func = getattr(requests, method.lower())
        try:
            resp = func(**params)
        except Exception as e:
            self.log.error("Call to %s failed with %s, %s" % (url, repr(e),
                                                              e.message))
            return None, e
        else:
            self.log.debug("Call to %s returned with status %s and body "
                           "%s" % (url, resp.status, resp.text))
        return resp.status_code, resp.json()
310157
def request_encode_url(self, method, url, fields=None, **urlopen_kw):
        
        if fields:
            url += '?' + urlencode(fields)
        return self.urlopen(method, url, **urlopen_kw)