Send a request to the Sugar Instance
197534
def send!(method, json, max_retry=3)
    if max_retry == 0
      raise SugarCRM::RetryLimitExceeded, "SugarCRM::Connection Errors: \n#{@errors.reverse.join "\n\s\s"}"
    end
    @request  = SugarCRM::Request.new(@url, method, json, @options[:debug])
    # Send Ze Request
    begin
      if @request.length > 3900
        @response = @connection.post(@url.path, @request)
      else
        @response = @connection.get(@url.path.dup + "?" + @request.to_s)
      end
      return handle_response
    # Timeouts are usually a server side issue
    rescue Timeout::Error => error
      @errors << error
      send!(method, json, max_retry.pred)
    # Lower level errors requiring a reconnect
    rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE, EOFError => error
      @errors << error
      reconnect!
      send!(method, json, max_retry.pred)
    # Handle invalid sessions
    rescue SugarCRM::InvalidSession => error
      @errors << error
      old_session = @sugar_session_id.dup
      login!
      # Update the session id in the request that we want to retry.
      json.gsub!(old_session, @sugar_session_id)
      send!(method, json, max_retry.pred)
    end    
  end
1274166
def send_request(self, *args, **kwargs):
        
        try:
            return super(JSHost, self).send_request(*args, **kwargs)
        except RequestsConnectionError as e:
            if (
                self.manager and
                self.has_connected and
                self.logfile and
                'unsafe' not in kwargs
            ):
                raise ProcessError(
                    '{} appears to have crashed, you can inspect the log file at {}'.format(
                        self.get_name(),
                        self.logfile,
                    )
                )
            raise six.reraise(RequestsConnectionError, RequestsConnectionError(*e.args), sys.exc_info()[2])
25808
private void sendRequest() {

        final String queryString = !eventSpinner.isEnabled() ? String.valueOf(queryEditText.getText()) : null;
        final String eventString = eventSpinner.isEnabled() ? String.valueOf(String.valueOf(eventSpinner.getSelectedItem())) : null;
        final String contextString = String.valueOf(contextEditText.getText());

        if (TextUtils.isEmpty(queryString) && TextUtils.isEmpty(eventString)) {
            onError(new AIError(getString(R.string.non_empty_query)));
            return;
        }

        final AsyncTask<String, Void, AIResponse> task = new AsyncTask<String, Void, AIResponse>() {

            private AIError aiError;

            @Override
            protected AIResponse doInBackground(final String... params) {
                final AIRequest request = new AIRequest();
                String query = params[0];
                String event = params[1];

                if (!TextUtils.isEmpty(query))
                    request.setQuery(query);
                if (!TextUtils.isEmpty(event))
                    request.setEvent(new AIEvent(event));
                final String contextString = params[2];
                RequestExtras requestExtras = null;
                if (!TextUtils.isEmpty(contextString)) {
                    final List<AIContext> contexts = Collections.singletonList(new AIContext(contextString));
                    requestExtras = new RequestExtras(contexts, null);
                }

                try {
                    return aiDataService.request(request, requestExtras);
                } catch (final AIServiceException e) {
                    aiError = new AIError(e);
                    return null;
                }
            }

            @Override
            protected void onPostExecute(final AIResponse response) {
                if (response != null) {
                    onResult(response);
                } else {
                    onError(aiError);
                }
            }
        };

        task.execute(queryString, eventString, contextString);
    }
175353
def _base_request(self, method):
        """"""
        request = E.Element(method)
        request.set('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd')
        request.append(self.client_auth)
        return request
1344814
def send_request(req=None, method=None, requires_response=True):
    """"""
    if req is None:
        return functools.partial(send_request, method=method,
                                 requires_response=requires_response)

    @functools.wraps(req)
    def wrapper(self, *args, **kwargs):
        params = req(self, *args, **kwargs)
        _id = self.send(method, params, requires_response)
        return _id
    wrapper._sends = method
    return wrapper
799677
def _request(self, http_method, relative_url='', **kwargs):
        """"""
        # It could be possible to call api.resource.get('/index')
        # but it would be non-intuitive that the path would resolve
        # to root of domain
        relative_url = self._remove_leading_slash(relative_url)

        # Add default kwargs with possible custom kwargs returned by
        # before_request
        new_kwargs = self.default_kwargs().copy()
        custom_kwargs = self.before_request(
            http_method,
            relative_url,
            kwargs.copy()
        )
        new_kwargs.update(custom_kwargs)

        response = requests.request(
            http_method,
            self._join_url(relative_url),
            **new_kwargs
        )

        return self.after_request(response)
839399
async def request(self, method, path, json=None):
        """"""
        url = 'https://{}:{}/api/'.format(self.host, self.port)
        url += path.format(site=self.site)

        try:
            async with self.session.request(method, url, json=json) as res:
                if res.content_type != 'application/json':
                    raise ResponseError(
                        'Invalid content type: {}'.format(res.content_type))
                response = await res.json()
                _raise_on_error(response)
                return response['data']

        except client_exceptions.ClientError as err:
            raise RequestError(
                'Error requesting data from {}: {}'.format(self.host, err)
            ) from None
370705
def _assemble_and_send_request(self):
        

        client = self.client
        # Fire off the query.
        return client.service.track(
                WebAuthenticationDetail=self.WebAuthenticationDetail,
                ClientDetail=self.ClientDetail,
                TransactionDetail=self.TransactionDetail,
                Version=self.VersionId,
                SelectionDetails=self.SelectionDetails,
                ProcessingOptions=self.ProcessingOptions)
354302
def send_request (operation, expression):
    
    
    base = 'https://newton.now.sh'
    url = '%s/%s/%s' % (base, operation, urllib.parse.quote(expression))
    
    with urllib.request.urlopen(url) as response:
        return handle_response(response)
339969
def request(self, msgtype, msgid, method, params=[]):
        """"""
        result = None
        error = None
        exception = None

        try:
            result = self.dispatch.call(method, params)
        except Exception as e:
            error = (e.__class__.__name__, str(e))
            exception = e

        if isinstance(result, Deferred):
            result.add_callback(self._result, msgid)
            result.add_errback(self._error, msgid)
        else:
            self.send_response(msgid, error, result)
1129622
function request(meth, url, headers, query, data, cb) {
    var req = SA(meth, url);
    if (headers) req.set(headers);
    if (query) req.query(query);
    if (data) req.send(data);
    return req.end(function(err, res) {
        if (err) return cb(err);
        return cb(null, res.text);
    });
}
150849
def _send_request(self):
        
        
        # Generate the hash variable and parameters
        self._generate_hash()
        params = self._get_params()
        
        # Make the SOAP request
        try:
            resp = self._endpoint(**params)
            logger.debug(resp)
        except WebFault, e:
            logger.exception('An error occurred while making the SOAP request.')
            return None
        
        # Convert XML response into a dictionary
        self.response = XmlDictConfig(ElementTree.XML(smart_str(resp)))
        
        # Normalize dictionary values
        self.response = normalize_dictionary_values(self.response)
        
        # Log all non OK status codes
        if self.response['status']['errorCode'] != 'OK':
            logger.error(resp)
        
        return self.response
801062
def sendRequest(self, name, args):
        """"""
        (respEvt, id) = self.newResponseEvent()
        self.sendMessage({"id":id, "method":name, "params": args})
        return respEvt
889644
def send_request(self, api_name, *api_args, **api_kwargs):
        
        return self.conn.request(api_name, *api_args, **api_kwargs)
615060
def request(self, method, url, body=None, content_type='application/json'):
        """"""
        headers = self.make_auth_headers(content_type)
        connection = http_client.HTTPSConnection(self.apibase)
        connection.request(method, url, body, headers=headers)
        response = connection.getresponse()
        data = response.read()
        connection.close()
        if response.status not in [200, 201]:
            raise SauceException('{}: {}.\nSauce Status NOT OK'.format(
                response.status, response.reason), response=response)
        return json.loads(data.decode('utf-8'))
480381
def _send(self, method, route, data, params, **kwargs):
        """"""
        route = self._fmt_route(route, params)
        log(_("sending {} request to {}").format(method.upper(), route))
        try:
            self.response = getattr(self._client, method.lower())(route, data=data, **kwargs)
        except BaseException as e:  # Catch all exceptions thrown by app
            log(_("exception raised in application: {}: {}").format(type(e).__name__, e))
            raise Failure(_("application raised an exception (rerun with --log for more details)"))
        return self
1241431
def _request(self, function, params, method='POST', headers={}):
        """"""
        
        if method is 'POST':
            params = urllib.parse.urlencode(params)
            headers = { "Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain" }
        
        path = '/%s/%s' % (self._version, function)
        
        self._conn.request(method, path, params, headers)
        return self._conn.getresponse()