Dispatches a request to the Razorpay HTTP API
352228
def request(self, method, path, **options):
        
        options = self._update_user_agent_header(options)

        url = "{}{}".format(self.base_url, path)

        response = getattr(self.session, method)(url, auth=self.auth,
                                                 verify=self.cert_path,
                                                 **options)
        if ((response.status_code >= HTTP_STATUS_CODE.OK) and
                (response.status_code < HTTP_STATUS_CODE.REDIRECT)):
            return response.json()
        else:
            msg = ""
            code = ""
            json_response = response.json()
            if 'error' in json_response:
                if 'description' in json_response['error']:
                    msg = json_response['error']['description']
                if 'code' in json_response['error']:
                    code = str(json_response['error']['code'])

            if str.upper(code) == ERROR_CODE.BAD_REQUEST_ERROR:
                raise BadRequestError(msg)
            elif str.upper(code) == ERROR_CODE.GATEWAY_ERROR:
                raise GatewayError(msg)
            elif str.upper(code) == ERROR_CODE.SERVER_ERROR:
                raise ServerError(msg)
            else:
                raise ServerError(msg)
695850
def dispatch_request(self, *args, **kwargs):
        """"""
        method = getattr(self, request.method.lower(), None)
        if method is None and request.method == 'HEAD':
            method = getattr(self, 'get', None)
        assert method is not None, 'Unimplemented method {}'.format(request.method)

        headers = {'Content-Type': 'application/vnd.api+json'}

        response = method(*args, **kwargs)

        if isinstance(response, Response):
            response.headers.add('Content-Type', 'application/vnd.api+json')
            return response

        if not isinstance(response, tuple):
            if isinstance(response, dict):
                response.update({'jsonapi': {'version': '1.0'}})
            return make_response(json.dumps(response, cls=JSONEncoder), 200, headers)

        try:
            data, status_code, headers = response
            headers.update({'Content-Type': 'application/vnd.api+json'})
        except ValueError:
            pass

        try:
            data, status_code = response
        except ValueError:
            pass

        if isinstance(data, dict):
            data.update({'jsonapi': {'version': '1.0'}})

        return make_response(json.dumps(data, cls=JSONEncoder), status_code, headers)
902085
def _request(self, action='GET', url='/', data=None, query_params=None):
        
        if data is None:
            data = {}
        if query_params is None:
            query_params = {}
        response = self.session.request(action, self.api[self.account]['endpoint'] + url,
                                        params=query_params, data=data)
        response.raise_for_status()
        return response
265391
def get(self, request, *args, **kwargs):
        """"""
        try:
            context = self.get_context_data(**kwargs)
        except exceptions.NotAvailable:
            exceptions.handle(request)
        self.set_workflow_step_errors(context)
        return self.render_to_response(context)
117554
def call(self, parameters):
        
        # DEV !
        parameters = {
            key: str(parameters[key]) for key in parameters if parameters[key] is not None
        }
        if self.inventory is not None and "inv" not in parameters:
            parameters["inv"] = self.inventory

        request = requests.get(self.endpoint, params=parameters)
        request.raise_for_status()
        if request.encoding is None:
            request.encoding = "utf-8"
        return request.text
47912
async def dispatch(self, request, view=None, **kwargs):
        """"""
        if view is None and request.method not in self.methods:
            raise HTTPMethodNotAllowed(request.method, self.methods)

        method = getattr(self, view or request.method.lower())
        response = await method(request, **kwargs)
        return await self.make_response(request, response)
675358
def do_request(self, request, proxies, timeout, **_):
        """"""
        print('{0} {1}'.format(request.method, request.url))
        response = self.http.send(request, proxies=proxies, timeout=timeout,
                                  allow_redirects=False)
        response.raw = None  # Make pickleable
        return response
1033830
def dispatch(self):
    """"""
    try:
      webapp2.RequestHandler.dispatch(self)
    finally:
      self.session_store.save_sessions(self.response)
343013
def dispatch!
      # Avoid passing frozen string in force_encoding
      @params.merge!(@request.params).each do |key, val|
        next unless val.respond_to?(:force_encoding)
        val = val.dup if val.frozen?
        @params[key] = force_encoding(val)
      end

      invoke do
        static! if settings.static? && (request.get? || request.head?)
        filter! :before
        route!
      end
    rescue ::Exception => boom
      invoke { handle_exception!(boom) }
    ensure
      begin
        filter! :after unless env['sinatra.static_file']
      rescue ::Exception => boom
        invoke { handle_exception!(boom) } unless @env['sinatra.error']
      end
    end
370004
function fetch(publicAPI, model, name) {
  let fetchCallback = null;
  const requestQueue = [];

  publicAPI[`set${capitalize(name)}FetchCallback`] = (fetchMethod) => {
    if (requestQueue.length) {
      fetchMethod(requestQueue);
    }
    fetchCallback = fetchMethod;
  };

  return {
    addRequest(request) {
      requestQueue.push(request);
      if (fetchCallback) {
        fetchCallback(requestQueue);
      }
    },
    resetRequests(requestList) {
      while (requestQueue.length) {
        requestQueue.pop();
      }
      if (requestList) {
        // Rebuild request list
        requestList.forEach((req) => {
          requestQueue.push(req);
        });
        // Also trigger a request
        if (fetchCallback) {
          fetchCallback(requestQueue);
        }
      }
    },
  };
}
1343087
private String getRedirectUrl(RequestParametersHolder requestHolder) throws AlipayApiException {
        StringBuffer urlSb = new StringBuffer(serverUrl);
        try {
            Map<String, String> sortedMap = AlipaySignature.getSortedMap(requestHolder);
            String sortedQuery = WebUtils.buildQuery(sortedMap, charset);
            urlSb.append("?");
            urlSb.append(sortedQuery);
        } catch (IOException e) {
            throw new AlipayApiException(e);
        }

        return urlSb.toString();
    }
1085104
def handle(self, request: HttpRequest) -> HttpResponse:
        
        self.__request_start = datetime.now()
        self.__request = request
        self.__uri = request.path[1:]
        self.__method = request.method

        # Initializes the callable controller and call it's connect method to get the mapped end-points.
        controller: RouteMapping = self.__controller().connect(self.app)

        self.__end_points = controller.get_routes()

        indent = self.get_json_ident(request.META)

        if self.set_end_point_uri() is False:
            return self.set_response_headers(self.no_route_found(self.__request).render(indent))

        response = HttpResponse(None)
        try:
            response = self.exec_route_callback()
        except RinzlerHttpException as e:
            client.captureException()
            self.app.log.error(f"< {e.status_code}", exc_info=True)
            response = Response(None, status=e.status_code)
        except RequestDataTooBig:
            client.captureException()
            self.app.log.error("< 413", exc_info=True)
            response = Response(None, status=413)
        except BaseException:
            client.captureException()
            self.app.log.error("< 500", exc_info=True)
            response = Response(None, status=500)
        finally:
            if type(response) == Response:
                return self.set_response_headers(response.render(indent))
            else:
                return self.set_response_headers(response)
1283738
def request(self, action, data={}, headers={}, method='GET'):
        
        data = self.merge(data, {'user': self.username, 'password': self.password, 'api_id': self.apiId})
        return Transport.request(self, action, data, headers, method)
258971
def dispatch(self, request, *args, **kwargs):
        
        # this part copied from django source code
        if request.method.lower() in self.http_method_names:
            handler = getattr(self, request.method.lower(),
                              self.http_method_not_allowed)
        else:
            handler = self.http_method_not_allowed
        # we changed only this line - removed first 'request' argument
        return handler(*args, **kwargs)
1186416
def dispatch(self,request,*args,**kwargs):
        '''
        
        '''
        paymentSession = request.session.get(INVOICE_VALIDATION_STR, {})
        self.invoiceID = paymentSession.get('invoiceID')
        self.amount = paymentSession.get('amount',0)
        self.success_url = paymentSession.get('success_url',reverse('registration'))

        # Check that Invoice matching passed ID exists
        try:
            i = Invoice.objects.get(id=self.invoiceID)
        except ObjectDoesNotExist:
            return HttpResponseBadRequest(_('Invalid invoice information passed.'))

        if i.unpaid or i.amountPaid != self.amount:
            return HttpResponseBadRequest(_('Passed invoice is not paid.'))

        return super(GiftCertificateCustomizeView,self).dispatch(request,*args,**kwargs)
529501
protected void executePatchRequest(URI uri, Object obj)
    {
        executePatchRequest(uri, obj, null, null);
    }
860757
def do_request(self, http_verb, url, headers, data=None):
        
        if data:
            data = json.dumps(data)
        request = urllib.request.Request(url, data, headers)
        request.get_method = lambda: http_verb

        try:
            response = urllib.request.urlopen(request)
        except urllib.error.HTTPError as response_:
            response = response_
        except urllib.error.URLError as exception:
            if isinstance(exception.reason, socket.timeout):  # Python 2.6
                self._raise_unrecoverable_error_payplug(exception)
            else:
                self._raise_unrecoverable_error_client(exception)
        except socket.timeout as exception:  # Python 2.7+
            self._raise_unrecoverable_error_payplug(exception)
        except http_client.HTTPException as exception:
            self._raise_unrecoverable_error_client(exception)

        return response.read(), response.code, dict(response.info())