所有接口用来发送请求的方法, 只是 :meth:`requests.sessions.Session.send` 的一个钩子方法, 用来处理请求前后的工作
354450
def send(self, request, **kwargs):
        
        response = super(BaseSession, self).send(request, **kwargs)
        if ENV['RAISE_FOR_STATUS']:
            response.raise_for_status()

        parsed = parse.urlparse(response.url)
        if parsed.netloc == parse.urlparse(self.host).netloc:
            response.encoding = ENV['SITE_ENCODING']
            # 快速判断响应 IP 是否被封, 那个警告响应内容长度为 327 或 328, 保留一点余量确保准确
            min_length, max_length, pattern = ENV['IP_BANNED_RESPONSE']
            if min_length <= len(response.content) <= max_length and pattern.search(response.text):
                msg = '当前 IP 已被锁定, 如果可以请尝试切换教务系统地址, 否则请在更换网络环境或等待解封后重试!'
                raise IPBanned(msg)

        self.histories.append(response)
        logger.debug(report_response(response, redirection=kwargs.get('allow_redirects')))
        return response
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
200893
async def send_request(self, method, args=()):
        ''''''
        message, event = self.connection.send_request(Request(method, args))
        return await self._send_concurrent(message, event, 1)
210610
def request(self, method, params, session):
        
        session = session or self.client.session
        request = self.create_req(method, params)
        date_time_sent = datetime.datetime.utcnow()
        try:
            response = session.post(
                self.url,
                data=request,
                headers=self.client.request_headers,
                timeout=(self.connect_timeout, self.read_timeout)
            )
        except ConnectionError:
            raise APIError(None, method, params, 'ConnectionError')
        except Exception as e:
            raise APIError(None, method, params, e)
        elapsed_time = (datetime.datetime.utcnow()-date_time_sent).total_seconds()

        check_status_code(response)
        try:
            response_data = response.json()
        except ValueError:
            raise InvalidResponse(response.text)

        if self._error_handler:
            self._error_handler(response_data, method, params)
        return response_data, elapsed_time
706126
function RAgent_send(name, body, cb) {
  if (!this._session) return

  var reqID = this._nextReqID()

  this._requestCBs.set(reqID, cb)

  var message = {
    type: "request",
    name: name,
    to:   this.info.id,
    id:   reqID,
    body: body
  }

  this._session._sendMessage(message)
}
540197
function send(httpMethod, path, req) {
    req = req || {};
    httpMethod = httpMethod.toUpperCase();

    var deferred = Q.defer();
    var url = baseUrl + path;
    var data = req.data || {};          // separate out data from request
    delete req.data;

    var isAdmin = req.caller && req.caller.role === 'admin';
    delete req.caller;

    var id = req._id || data._id;       // get id from request or data
    if (req._id) { delete req._id; }    // delete id from request so no dupe

    var session = cls.getNamespace('appSession');
    var caller = session && session.active && session.get('caller');
    if (caller && !isAdmin) {
        _.extend(req, {                 // onBehalfOf used by API to know who is the caller
            onBehalfOfType: caller.type,
            onBehalfOfId:   caller._id + '',
            onBehalfOfRole: caller.role,
            onBehalfOfName: caller.name
        });
    }

    _.each(req, function (val, key) {
        if (!_.isString(val)) { req[key] = JSON.stringify(val); }
    });

    // replace the ID portion of the URL
    url = id ?
        url.replace('{_id}', id + '') :
        url.replace('/{_id}', '');

    var reqConfig = {
        headers:    headers,
        url:        url,
        method:     httpMethod,
        qs:         _.isEmpty(req) ? undefined : req,
        json:       _.isEmpty(data) ? true : data
    };

    // if baseUrl not there yet, wait for 100 seconds until it is (i.e. during system startup)
    if (!baseUrl) {
        setTimeout(function () {
            makeRequest(reqConfig, deferred);
        }, 100);
    }
    else {
        makeRequest(reqConfig, deferred);
    }

    return deferred.promise;
}
161535
def _request(self, method, url, **kwargs):
        # type: (str, str, **Any) -> requests.Response
        """"""
        self.last_request = None
        self.last_response = self.session.request(method, url, auth=self.auth, headers=self.headers, **kwargs)
        self.last_request = self.last_response.request
        self.last_url = self.last_response.url

        if self.last_response.status_code == requests.codes.forbidden:
            raise ForbiddenError(self.last_response.json()['results'][0]['detail'])

        return self.last_response
358790
def _send_request(self, request, **kwargs):
        """"""
        log.debug(LOG_CHECK, "Send request %s with %s", request, kwargs)
        log.debug(LOG_CHECK, "Request headers %s", request.headers)
        self.url_connection = self.session.send(request, **kwargs)
        self.headers = self.url_connection.headers
        self._add_ssl_info()
913662
def send(self, **kwargs):
        
        return_full_object = kwargs.get('return_full_object', False)
        _verbose = kwargs.get('_verbose', False)
        traversal = kwargs.get('traversal', None)
        timeout = kwargs.get('_timeout', 5)
        self.output['url'] = self.render_url()
        with VerboseContextManager(verbose=_verbose):
            try:
                resp = Response(self.action.format(), request(timeout=timeout, **self.output), traversal)
            except HTTPError as err:
                raise ResponseException(self.action.format(), err)
            except socket.timeout:
                raise RequestTimeout(functools.partial(self.send, **kwargs))
            except URLError as err:
                if isinstance(err.reason, socket.timeout):
                    raise RequestTimeout(functools.partial(self.send, **kwargs))
                else:
                    raise

        if return_full_object:
            return resp
        else:
            return resp.read()
1094408
def method_missing(name, *args, &block)
        context_scope.respond_to?(name, true) ? context_scope.__send__(name, *args, &block) : super
      end
572975
def request(self, session_id):
        
        node = new_ele("kill-session")
        sub_ele(node, "session-id").text = session_id
        return self._request(node)
513311
def _put_request(self, url, headers, data=None):
        
        return self._session.put(url, headers=headers, data=data)
822710
def session(self):
        
        if self._session is None:
            self._session = requests.Session()
            self._session.headers.update(self._headers)
        return self._session
1187393
def send_request(id, method, params)
      data = MessagePack.dump([0, id, method, params]).bytes
      ws.send(data)
    rescue => exc
      warn exc
      abort exc
    end
427221
def request(self, method, url, **kwargs):
        
        auth = None
        if self._username is not None and self._password is not None:
            auth = (self._username, self._password)

        return super(BasicSession, self).request(
            method, url, auth=auth, **kwargs)
919124
def send(self, request, **kwargs):
        
        if len(request.url) > self.MAX_URL_LENGTH:
            raise URITooLong(
                message=(
                    'Request url too large, '
                    'likely too many query parameters provided.'
                )
            )
        return super(RequestSession, self).send(request, **kwargs)
777381
def send(self, **kwargs):
        
        merged_kwargs = {}
        merged_kwargs.update(self.kwargs)
        merged_kwargs.update(kwargs)
        try:
            self.response = self.session.request(self.method,
                                                self.url, **merged_kwargs)
        except Exception as e:
            self.exception = e
            self.traceback = traceback.format_exc()
        return self