__request.

        make the actual request. This method is called by the
        request method in case of 'regular' API-calls. Or indirectly by
        the__stream_request method if it concerns a 'streaming' call.
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
891841
def prepare_request(self, *args, **kw):
        
        self.http_request = self.request_class(self.path, *args, **kw)
823244
protected function _makeRequest()
    {
        # Check for cURL. If it isn't loaded, fall back to fopen()
        if(function_exists('curl_init'))
            $this->_rawResponse = $this->_makeCurlRequest($this->_url);
        else
            $this->_rawResponse = $this->_makeFOpenRequest($this->_url);
    }
479404
def request(self, method, url, *args):
        
        return self.http.request(method, url, *args)
969413
def do(self):
        
        data = None
        if self.body is not None and self.body != b'':
            data = self.body
        return requests.request(self.method, str(self.url), data=data, headers=self.header)
437508
def request(self, *args, **kwargs):
        
        func = partial(super().request, *args, **kwargs)
        return self.loop.run_in_executor(self.thread_pool, func)
1148173
def setup_streaming(request)
      if(request.body && request.body.respond_to?(:read))
        body = request.body
        request.content_length = body.respond_to?(:lstat) ? body.lstat.size : body.size
        request.body_stream = request.body
        true
      end
    end
407968
def request(self, method, url, **kwargs):
        '''
        '''
        # TODO should we raise an exception if auth or cookies are explicitly
        # mentioned in kwargs?
        kwargs['auth'] = self.auth()
        kwargs['cookies'] = self.cookies
        return requests.request(method=method, url=url, **kwargs)
373353
def request(method, path, options, raw=false)
      before_request
      response = connection(raw).send(method) do |request|
        case method
        when :get, :delete
          request.url(formatted_path(path), options)
        when :patch, :post, :put
          request.path = formatted_path(path)
          request.headers['Content-Type'] = 'application/json'
          request.body = options.to_json unless options.empty?
        end
      end
      raw ? response : response.body
    end
77924
def send(self, stream_to_file=None):
        
        try:
            self._stage = STAGE_REQUEST
            self.prepared_request.prepare(method=self.method,
                                          url=self.endpoint_url,
                                          files=self.files,
                                          json=self.json,
                                          data=self.data,
                                          headers=self.headers,
                                          params=self.params,
                                          cookies=self.cookies,
                                          hooks=self.hooks)

        except Exception as e1:
            self.error = ApiError(
                "Exception in making Request with:: %s\n%s" % (
                    e1, traceback.format_exc()))
            raise Exception(self.error)

        try:
            self._stage = STAGE_SENDING
            self._timestamps['send'] = time.time()
            self.response = self.session.send(self.prepared_request,
                                              proxies=self.proxies,
                                              timeout=self.timeout,
                                              stream=bool(stream_to_file),
                                              verify=VERIFY,
                                              cert=None)
            self._stage = STAGE_RESPONDING
            self._timestamps['receive'] = time.time()
        except Exception as e2:
            self._timestamps.setdefault('exception', time.time())
            self.error = e2
            raise

        self.post_process(stream_to_file)
        self._stage = ((self.name == 'Unknown') and
                       STAGE_DONE_DATA_FORMATTED or STAGE_DONE)
        return self.data
1104833
def _make_request(
            self, api_resource, method='GET', params=None, **kwargs):
        
        if kwargs.get('json'):
            headers = {
                'Authorization': 'Bearer {}'.format(self._token),
                'Content-Type': 'application/json'
            }
        else:
            headers = {
                'Authorization': 'Bearer {}'.format(self._token)
            }

        response = requests.request(
            method=method,
            url='{0}{1}'.format(self.BASE_API_URL, api_resource),
            headers=headers,
            params=params,
            **kwargs
        )

        if response.status_code >= 400:
            error_response = response.json()

            raise(ToshlException(
                status_code=response.status_code,
                error_id=error_response['error_id'],
                error_description=error_response['description'],
                extra_info=error_response.get('fields')))

        return response
892280
def request(self, method, url, data=None, files=None, query=None, headers=None, timeout=60):
        
        headers = headers or {}

        if self.token:
            my_token = self.token
        else:
            from figure import token
            my_token = token

        if my_token:
            self.__set_authorization(headers, my_token)

        METHODS = {
            'get': self.__get,
            'post': self.__post,
            'put': self.__put,
            'head': self.__head,
            'patch': self.__patch
        }
        request_method = METHODS[method.lower()]

        abs_url = urlparse.urljoin(self.api_base, url)

        encoded_query = urllib.urlencode(query or {})

        abs_url = _build_api_url(abs_url, encoded_query)

        try:
            response = request_method(abs_url, data=data, files=files, headers=headers, timeout=timeout)
            response.encoding = 'utf-8'
        except RequestException:
            raise error.APIConnectionError()

        return self._interpret_response(response.text, response.status_code)
1022591
def _make_request(self, url, **kwargs):
        
        response = requests.post(url, **kwargs)
        try:
            return response.json()
        except ValueError:
            pass
        return parse_qs(response.content)
1247890
def post_request(self, request, response):
        # type: (BaseHttpRequest, HttpResponse) -> HttpResponse
        
        if request.method != api.Method.OPTIONS:
            response.headers.update(self.request_headers(request))
        return response
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
1263699
def create_request(self, method='', url='', query_params=None, body=None, headers=None):
        

        if query_params:
            query = urlencode(query_params)
            if query:
                url = url + ('&' if url.find('?') > 0 else '?') + query

        content_type = None
        accept = None

        if headers is None:
            headers = {}

        it = iterator(headers)

        for key, value in it:
            if key.lower().find('content-type') >= 0:
                content_type = value
            if key.lower().find('accept') >= 0:
                accept = value

        if content_type is None:
            content_type = 'application/json'
            headers['Content-Type'] = content_type

        if accept is None:
            accept = 'application/json'
            headers['Accept'] = accept

        if content_type.lower().find('application/json') >= 0:
            body = json.dumps(body) if body else None
        elif content_type.lower().find('application/x-www-form-urlencoded') >= 0:
            body = urlencode(body) if body else None

        return requests.Request(method, url, headers=headers, data=body)
284492
def build_request(self, input_data=None, api_data=None, aux_data=None, *args, **kwargs):
        
        if input_data is not None:
            self.client_data = input_data
        if api_data is not None:
            self.api_data = api_data
        if aux_data is not None:
            self.aux_data = aux_data

        self.request = RequestHolder()
        self.request.nonce = get_random_vector(EBConsts.FRESHNESS_NONCE_LEN)

        self.request.endpoint = self.get_endpoint()
        self.request.url = self.get_endpoint().get_url() + self.url_suffix

        self.request.configuration = self.config
        self.request.api_method = self.operation
        self.request.headers = {'X-Auth-Token': 'public'}

        # Result request body
        self.request.body = {
            'nonce': to_hex(self.request.nonce),
            'version': 1,
            'function': self.operation,
            'environment': self.env if self.env is not None else ENVIRONMENT_DEVELOPMENT,
        }

        if self.client_data is not None:
            self.request.body['client'] = self.client_data
        if self.api_data is not None:
            self.request.body['apidata'] = self.api_data
        if self.aux_data is not None:
            if isinstance(self.aux_data, dict):
                self.request.body = EBUtils.merge(self.request.body, self.aux_data)
            else:
                raise ValueError('Aux data has to be a dictionary')

        self.request = self.extend_request(self.request)
        return self.request