Perform a http(s) request for given parameters to given URL

            Keyword arguments:
            url -- API url
            parameters -- dict with payload.
971790
def request(self, url, parameters):
        

        try:
            request = Request(url + '?' + urlencode(parameters), None, {
                'X-Authentication-Token': self.api_key,
                'User-Agent': self.user_agent
                },
                None,
                False,
                "GET"
            )

            response = urlopen(request)
        except HTTPError as e:
            self.logger.error('Code: ' + str(e.code))
            self.logger.error('Response: ' + str(e.reason))

            if e.code == 400:
                raise UnknownOutputFormatException()

            if e.code == 401:
                raise AuthorizationRequiredException()

            if e.code == 402:
                raise NotEnoughCreditsException()

            if e.code == 403:
                raise AccessDeniedException()

            if e.code == 422:
                raise InvalidMacOrOuiException()

            if e.code >= 500:
                raise ServerErrorException("Response code: {}".format(e.code))

            raise ServerErrorException(e.reason)

        if response.code >= 300 or response.code < 200:
            raise ServerErrorException("Response code: {}".format(response.code))

        headers = dict(response.getheaders())
        if "Warning" in headers.keys():
            self.logger.warning(headers["Warning"])

        self.logger.debug(response.info())

        return response.read()
820349
function request(url, payload) {
  return fetch(url, {
    method: 'POST',
    // set to 1000 b/c no response needed
    timeout: 1000,
    body: JSON.stringify(payload),
  })
  .then((response) => {
    if (response.status === 404) {
      return BbPromise.reject('404 api not found');
    }
    return response.json();
  })
  .then((res) => BbPromise.resolve(res))
  .catch((e) => BbPromise.resolve(e));
}
479404
def request(self, method, url, *args):
        
        return self.http.request(method, url, *args)
649227
def _do_request(self, url, params=None, data=None, headers=None):
        

        if not headers:
            headers = {'content-type': 'application/json'}

        try:
            response = requests.get(
                url, params=params, data=data, headers=headers)
        except:
            return None

        if response.status_code == 200:
            return response
947638
def _api_post(self, url, **kwargs):
        
        kwargs['url'] = self.url + url
        kwargs['auth'] = self.auth

        headers = deepcopy(self.headers)
        headers.update(kwargs.get('headers', {}))
        kwargs['headers'] = headers
        self._post(**kwargs)
921554
def _http_get(self, url, query, **kwargs):
        

        self._normalize_query(query)

        kwargs.update({'params': query})

        return self._http_request('get', url, kwargs)
977373
def __request(self, method, url, request_args, headers=None, stream=False):
        
        func = getattr(self.client, method)
        headers = headers if headers else {}
        response = None
        try:
            logger.info("performing request %s", url)
            response = func(url, stream=stream, headers=headers,
                            **request_args)
        except requests.RequestException as err:
            logger.error("request %s failed [%s]", url, err)
            raise err

        # Handle error responses
        if response.status_code >= 400:
            logger.error("request %s failed [%d,%s]",
                         url,
                         response.status_code,
                         response.content.decode('utf-8'))
            raise V20Error(response.status_code,
                           response.content.decode('utf-8'))
        return response
1139827
def _post(url:str, params:dict, headers:dict) -> dict:
    
    response = requests.post(url, params=params, headers=headers)
    data = response.json()
    if response.status_code != 200 or "error" in data:
        raise GoogleApiError({"status_code": response.status_code,
                                  "error": data.get("error", "")})
    return data
1145210
def _request(self, url, values=None):
        
        if values:
            json_data = json.dumps(values)
            request = urllib2.Request(url, json_data.encode())
            request.add_header('content-type', 'application/json')
            request.add_header('authorization', self._auth)
            connection = urllib2.urlopen(request)
            response = connection.read()
            connection.close()
        else:
            request = urllib2.Request(url)
            request.add_header('authorization', self._auth)
            connection = urllib2.urlopen(request)
            response = connection.read()
            connection.close()

        try:
            result = json.loads(response.decode())
        except ValueError as exception:
            return {'errorCode': 1, 'message': str(exception)}

        return result
651228
def _api_get(self, url, **kwargs):
        
        kwargs['url'] = self.url + url
        kwargs['auth'] = self.auth

        headers = deepcopy(self.headers)
        headers.update(kwargs.get('headers', {}))
        kwargs['headers'] = headers
        return self._get(**kwargs)
1321277
def request(method, uri, *args, **kwargs):
    
    req_method = req_methods[method.upper()]
    raise_exception = kwargs.pop("raise_exception", True)
    raw_content = kwargs.pop("raw_content", False)
    kwargs["headers"] = kwargs.get("headers", {})
    http_log_req(method, uri, args, kwargs)
    data = None
    if "data" in kwargs:
        # The 'data' kwarg is used when you don't want json encoding.
        data = kwargs.pop("data")
    elif "body" in kwargs:
        if "Content-Type" not in kwargs["headers"]:
            kwargs["headers"]["Content-Type"] = "application/json"
        data = json.dumps(kwargs.pop("body"))
    if data:
        resp = req_method(uri, data=data, **kwargs)
    else:
        resp = req_method(uri, **kwargs)
    if raw_content:
        body = resp.content
    else:
        try:
            body = resp.json()
        except ValueError:
            # No JSON in response
            body = resp.content
    http_log_resp(resp, body)
    if resp.status_code >= 400 and raise_exception:
        raise exc.from_response(resp, body)
    return resp, body
1120855
def send(url, data):
    
    validate(data)

    return requests.post(url, json=data)
661675
def _make_api_call(self, method, url, json_params=None):
        
        if self.verbose is True:
            print "\ncrossbarhttp: Request: %s %s" % (method, url)

        if json_params is not None:
            encoded_params = json.dumps(json_params)
            headers = {'Content-Type': 'application/json'}
        else:
            encoded_params = None
            headers = {}

        if encoded_params is not None and self.verbose is True:
            print "crossbarhttp: Params: " + encoded_params

        if self.key is not None and self.secret is not None and encoded_params is not None:
            signature, nonce, timestamp = self._compute_signature(encoded_params)
            params = urllib.urlencode({
                "timestamp": timestamp,
                "seq": str(self.sequence),
                "nonce": nonce,
                "signature": signature,
                "key": self.key
            })
            if self.verbose is True:
                print "crossbarhttp: Signature Params: " + params
            url += "?" + params

        # TODO: I can't figure out what this is.  Guessing it is a number you increment on every call
        self.sequence += 1

        try:
            request = urllib2.Request(url, encoded_params, headers)
            request.get_method = lambda: method
            response = urllib2.urlopen(request).read()
            if self.verbose is True:
                print "crossbarhttp: Response: " + response

            return json.loads(response)

        except urllib2.HTTPError, e:
            if e.code == 400:
                raise ClientMissingParams(str(e))
            elif e.code == 401:
                raise ClientSignatureError(str(e))
            else:
                raise ClientBadUrl(str(e))
        except urllib2.URLError, e:
            raise ClientBadHost(str(e))
546901
def _options_request(self, url, **kwargs):
        
        '''  '''
        
    # construct request kwargs
        request_kwargs = {
            'method': 'OPTIONS',
            'url': url
        }
        for key, value in kwargs.items():
            request_kwargs[key] = value

    # send request and handle response
        return self._request(**request_kwargs)
272508
def _init_request_urls(self, api_urls):
        
        if not isinstance(api_urls, (str, list, tuple)):
            raise TypeError('api_urls needs to be string or iterable!')

        if isinstance(api_urls, str):
            api_urls = (api_urls,)

        api_urls = list(api_urls)

        for url in api_urls:
            if not url.startswith('http://') and \
               not url.startswith('https://'):
                raise ValueError(('URL "%s" contains an invalid or missing'
                                 ' scheme' % (url)))

        return list(api_urls)
559772
def _requests(self, url, method='GET', headers=None, params=None, data=None, errors=None):

        '''  '''

        title = '%s._requests' % self.__class__.__name__
    
    # import dependencies
        from time import time
        import requests

    # validate access token
        if not self._access_token:
            self.access_token()
            if self.retrieve_details:
                self._get_products()
    
    # refresh token
        current_time = time()
        if current_time > self.expires_at:
            self.access_token()
            if self.retrieve_details:
                self._get_products()

    # construct request kwargs
        request_kwargs = {
            'url': url,
            'headers': { 
                'Authorization': 'Bearer %s' % self._access_token,
                'Accept': 'application/json;v=2'
            },
            'params': {},
            'data': {}
        }
        if headers:
            request_kwargs['headers'].update(headers)
        if params:
            request_kwargs['params'].update(params)
        if data:
            request_kwargs['data'].update(data)

    # send request
        if method == 'POST':
            try:
                response = requests.post(**request_kwargs)
            except Exception:
                if self.requests_handler:
                    request_kwargs['method'] = 'POST'
                    request_object = requests.Request(**request_kwargs)
                    return self.requests_handler(request_object)
                else:
                    raise
        elif method == 'GET':
            try:
                response = requests.get(**request_kwargs)
            except Exception:
                if self.requests_handler:
                    request_kwargs['method'] = 'GET'
                    request_object = requests.Request(**request_kwargs)
                    return self.requests_handler(request_object)
                else:
                    raise
        else:
            raise ValueError('%s(method='') must be either GET or POST' % title)

    # handle response
        response_details = self.response_handler.handle(response, errors)
        
        return response_details
192426
def request(self, uri, method, *args, **kwargs):
        
        if self.timeout:
            kwargs["timeout"] = self.timeout
        kwargs["verify"] = self.verify_ssl
        kwargs.setdefault("headers", kwargs.get("headers", {}))
        kwargs["headers"]["User-Agent"] = self.user_agent
        kwargs["headers"]["Accept"] = "application/json"
        if ("body" in kwargs) or ("data" in kwargs):
            if "Content-Type" not in kwargs["headers"]:
                kwargs["headers"]["Content-Type"] = "application/json"
            elif kwargs["headers"]["Content-Type"] is None:
                del kwargs["headers"]["Content-Type"]
        # Allow subclasses to add their own headers
        self._add_custom_headers(kwargs["headers"])
        resp, body = pyrax.http.request(method, uri, *args, **kwargs)
        if resp.status_code >= 400:
            raise exc.from_response(resp, body)
        return resp, body