Requests wrapper function
490800
def request(self, method, url, parameters=dict()):
        """"""

        # The requests library uses urllib, which serializes to "True"/"False" while Pingdom requires lowercase
        parameters = self._serializeBooleans(parameters)

        headers = {'App-Key': self.apikey}
        if self.accountemail:
            headers.update({'Account-Email': self.accountemail})

        # Method selection handling
        if method.upper() == 'GET':
            response = requests.get(self.url + url, params=parameters,
                                    auth=(self.username, self.password),
                                    headers=headers)
        elif method.upper() == 'POST':
            response = requests.post(self.url + url, data=parameters,
                                     auth=(self.username, self.password),
                                     headers=headers)
        elif method.upper() == 'PUT':
            response = requests.put(self.url + url, data=parameters,
                                    auth=(self.username, self.password),
                                    headers=headers)
        elif method.upper() == 'DELETE':
            response = requests.delete(self.url + url, params=parameters,
                                       auth=(self.username, self.password),
                                       headers=headers)
        else:
            raise Exception("Invalid method in pingdom request")

        # Store pingdom api limits
        self.shortlimit = response.headers.get(
            'Req-Limit-Short',
            self.shortlimit)
        self.longlimit = response.headers.get(
            'Req-Limit-Long',
            self.longlimit)

        # Verify OK response
        if response.status_code != 200:
            sys.stderr.write('ERROR from %s: %d' % (response.url,
                                                    response.status_code))
            sys.stderr.write('Returned data: %s\n' % response.json())
            response.raise_for_status()

        return response
304633
def wrap_session_request(wrapped, instance, args, kwargs):
    """"""
    method = kwargs.get('method') or args[0]
    url = kwargs.get('url') or args[1]

    blacklist_hostnames = execution_context.get_opencensus_attr(
        'blacklist_hostnames')
    parsed_url = urlparse(url)
    if parsed_url.port is None:
        dest_url = parsed_url.hostname
    else:
        dest_url = '{}:{}'.format(parsed_url.hostname, parsed_url.port)
    if utils.disable_tracing_hostname(dest_url, blacklist_hostnames):
        return wrapped(*args, **kwargs)

    _tracer = execution_context.get_opencensus_tracer()
    _span = _tracer.start_span()

    _span.name = '[requests]{}'.format(method)
    _span.span_kind = span_module.SpanKind.CLIENT

    try:
        tracer_headers = _tracer.propagator.to_headers(
            _tracer.span_context)
        kwargs.setdefault('headers', {}).update(
            tracer_headers)
    except Exception:  # pragma: NO COVER
        pass

    # Add the requests url to attributes
    _tracer.add_attribute_to_current_span(HTTP_URL, url)

    result = wrapped(*args, **kwargs)

    # Add the status code to attributes
    _tracer.add_attribute_to_current_span(
        HTTP_STATUS_CODE, str(result.status_code))

    _tracer.end_span()
    return result
851126
function getMiddlewareWrapper( middleware ) {
	return function ( req, res, next ) {
		try {
			middleware( req, res, next );
		}
		catch ( e ) {
			getResponder( req, res )( 500 );
		}
	};
}
700569
function wrap(fn) {
  // Error handling middleware
  if (fn.length === 4) {
    return async function wrappedErrorHandler(error, req, res, next) {
      next = _once(next);
      try {
        await fn(error, req, res, next);
        res.headersSent ? null : next();
      } catch(err) {
        res.headersSent ? null : next(err);
      }
    };
  }

  return async function wrappedMiddleware(req, res, next) {
    next = _once(next);
    try {
      await fn(req, res, next);
      res.headersSent ? null : next();
    } catch(err) {
      res.headersSent ? null : next(err);
    }
  };
}
213229
def _request(self, **kwargs):
        
        '''  '''
        
        response = None
        error = ''
        code = 0
        
    # send request
        from requests import request
        try:
            response = request(**kwargs)
        # handle response
            if self.handle_response:
                response, error, code = self.handle_response(response)
            else:
                code = response.status_code
    # handle errors
        except Exception as err:
            from requests import Request
            request_object = Request(**kwargs)
            try:
                request_details = self.handle_requests(request_object)
                error = request_details['error']
            except:
                error = str(err)
                
        return response, error, code
1025132
def xml_request(check_object=False, check_invalid_data_mover=False):
    

    def decorator(f):
        @functools.wraps(f)
        def func_wrapper(self, *argv, **kwargs):
            request = f(self, *argv, **kwargs)
            return self.request(
                request, check_object=check_object,
                check_invalid_data_mover=check_invalid_data_mover)

        return func_wrapper

    return decorator
725753
def _request(self, url, method="GET", params=None, api_call=None):
        """"""
        method = method.lower()
        params = params or {}
        func = getattr(requests, method)
        requests_args = {}
        if method == "get" or method == "delete":
            requests_args["params"] = params
        else:
            if params.get("json"):
                requests_args["json"] = params.get("json")
            if params.get("files"):
                requests_args["files"] = params.get("files")
            if params.get("data"):
                requests_args["data"] = params.get("data")
        try:
            response = func(url, **requests_args)
        except requests.RequestException as e:
            raise SafecastPyError(str(e))
        # greater than 304 (not modified) is an error
        if response.status_code > 304:
            if response.status_code == 401:
                raise SafecastPyAuthError(response.json().get("error"))
            if response.status_code in [422]:
                raise SafecastPyError(response.json().get("errors"))
            raise SafecastPyError(response.content, error_code=response.status_code)
        try:
            if response.status_code == 204:
                content = response.content
            else:
                content = response.json()
        except ValueError:
            raise SafecastPyError(
                "Response was not valid JSON. \
                               Unable to decode."
            )
        return content
670329
def json_wrap(function, *args, **kwargs):
    ''''''
    try:
        # Some responses have data = None, but they generally signal a
        # successful API call as well.
        response = json.loads(function(*args, **kwargs).content)
        if 'data' in response:
            return response['data'] or True
        else:
            return response
    except Exception as exc:
        raise ClientException(exc)
280974
def request(self, request_type):
        '''  '''

        def _handler(func):
            self._handlers[request_type] = func
            return func

        return _handler
899501
def s3_request(func: Callable):
    

    @wraps(func)
    def wrapper(url: str, *args, **kwargs):
        try:
            return func(url, *args, **kwargs)
        except ClientError as exc:
            if int(exc.response["Error"]["Code"]) == 404:
                raise FileNotFoundError("file {} not found".format(url))
            else:
                raise

    return wrapper
290823
def json_request(endpoint, verb='GET', session_options=None, **options):
    
    req = functools.partial(_request, endpoint, verb, session_options,
                            json=True, **options)
    return _run_in_fresh_loop(req)
356898
function(options) {
		var length = this.promises.length,
			last = this.promises[length - 1];
		if (length && last) {
			last.rqMethod = function(scraper, url) {
				options.uri = url;
				scraper.request(options);
			};
			return this;
		} else {
			throw new ScraperError('');
		}
	}
294385
def jsonp(func):
    """"""
    @wraps(func)
    def decorated(*args, **kwargs):
        callback = request.args.get('callback', False)
        if callback:
            data = str(func(*args, **kwargs).data)
            content = str(callback) + '(' + data + ')'
            mimetype = 'application/javascript'
            return current_app.response_class(content, mimetype=mimetype)
        else:
            return func(*args, **kwargs)
    return decorated
230549
def request(self, *args, **kwargs):
        
        return self.session.request(*args, **self.get_kwargs(**kwargs))
1205936
function Requests(apiUrl, version, publicKey) {
    this.apiUrl = stripSlashes(apiUrl);
    this.version = version.toString();
    this.publicKey = publicKey;
}
1052193
function createRequestWrapper(req) {
        var status,
            statusText,
            responseText;
        try {
            status = req.status;
            statusText = req.statusText;
            responseText = req.responseText;
        } catch (e) {
            status = 0;
            statusText = '';
            responseText = null;
        }
        return {
            status: status,
            statusText: statusText,
            responseText: responseText,
            rawRequest: req
        };
    }
576483
function requestHandler (method) {
  return function (req, res, next) {
    method.call(this, req, responseHandler(res, next));
  }.bind(this);
}