PrivateFunction: _connect_cb
_Private_ function called by Strophe.Connection._connect_cb

checks for stream:error

Parameters:
(Strophe.Request) bodyWrap - The received stanza.
505619
function(bodyWrap) {
        var error = this._check_streamerror(bodyWrap, Strophe.Status.CONNFAIL);
        if (error) {
            return Strophe.Status.CONNFAIL;
        }
    }
138241
def unwrap_stream(stream_name):
    
    wrapped_stream = None
    try:
        wrapped_stream = getattr(sys, stream_name)
        if hasattr(wrapped_stream, '_original_stream'):
            setattr(sys, stream_name, wrapped_stream._original_stream)
        yield
    finally:
        if wrapped_stream:
            setattr(sys, stream_name, wrapped_stream)
1122530
function wrapCallback(callback)
{
  var stream = this;

  var wrapped = function(error, result)
  {
    return finisher.call(stream, error, result, callback);
  };

  return wrapped;
}
1273893
function parseBody(req, limit, callback) {
  const body = [];

  function handleData(data) {
    body.push(data);

    /**
    Stop collecting data and call the callback with an error if request exceeds limit.
    Calling function should close the connection.
    */
    if (Buffer.concat(body).length > limit) {
      req.removeListener('data', handleData);
      req.removeListener('end', handleEnd);

      const error = new Error();
      error.httpCode = 413;
      error.message = http.STATUS_CODES[413];

      callback(error);
    }
  }

  function handleEnd() {
    const type = req.headers['content-type'];

    if (type === 'application/x-www-form-urlencoded') {
      callback(null, querystring.parse(Buffer.concat(body).toString()));

    } else if (type === 'application/json') {
      callback(null, JSON.parse(Buffer.concat(body).toString()));

    } else {
      callback(null, Buffer.concat(body).toString());
    }
  }

  req.on('data', handleData);
  req.on('end', handleEnd);
}
1051889
def process_request_body(fn):
    '''
    
    '''
    @functools.wraps(fn)
    def wrapped(*args, **kwargs):  # pylint: disable=C0111
        if cherrypy.request.process_request_body is not False:
            fn(*args, **kwargs)
    return wrapped
319888
function wrap_cb(fn, P) {
  return function (params) {
    return new P(function (resolve, reject) {
      fn(params, function (err) { return !err ? resolve() : reject(err); });
    });
  };
}
159554
def apize_raw(url, method='GET'):
	
	def decorator(func):
		def wrapper(*args, **kwargs):
			elem = func(*args, **kwargs)

			if type(elem) is not dict:
				raise BadReturnVarType(func.__name__)

			response = send_request(url, method, 
				elem.get('data', {}),
				elem.get('args', {}),
				elem.get('params', {}),
				elem.get('headers', {}),
				elem.get('cookies', {}),
				elem.get('timeout', 8),
				elem.get('is_json', False),
				elem.get('verify_cert', True)
			)

			return response
		return wrapper

	return decorator
1260979
function(base_url, callback, cors) {
    var recv = new XhrReceiver(base_url + '/chunking_test', {cors: cors});
    var result = 0;
    recv.onmessage = function(e) {
        // Now a cool hack: we can stop receiving after we got at least
        // one chunk, contains some data, but not everyting.
        var l = e.responsetext.split('h\n').length;
        if(e.readystate === 3 && l > 0 && l < 6 ) {
            result = l;
            recv.abort();
        }
    };
    recv.onclose = function(e) {
        recv = recv.onmessage = recv.onclose = null;
        utils.log('Chunking test: ' + (result ? 'passed' : 'failed')
                  + ' (' + result + ' chunk received)');
        callback(!!result);
    };
}
242390
function logWrap(level) {
    return function log() {
      let context, message, args, trace, err;

      if (arguments[0] instanceof Error) {
        // log.<level>(err, ...)
        context = API.getContext();
        args = Array.prototype.slice.call(arguments, 1);
        if (!args.length) {
          // log.<level>(err)
          err = arguments[0];
          message = err.name + ': ' + err.message;
        } else {
          // log.<level>(err, "More %s", "things")
          // Use the err as context information
          err = arguments[0];
          message = arguments[1];
          args = Array.prototype.slice.call(args, 1);
        }
      } else if (arguments[0] == null || (typeof (arguments[0]) !== 'object' && arguments[0] !== null) ||
          Array.isArray(arguments[0])) {
        // log.<level>(msg, ...)
        context = API.getContext();
        message = arguments[0];
        args = Array.prototype.slice.call(arguments, 1);
      } else {
        // log.<level>(fields, msg, ...)
        context = merge(API.getContext(), arguments[0]);
        message = arguments[1];
        args = Array.prototype.slice.call(arguments, 2);
      }

      trace = API.format(level, context || {}, message, args, err);
      API.stream.write(trace + '\n');
    };
  }
1025404
def connected(func):
    
    @wraps(func)
    def wrapper(*args, **kwargs):
        self = args[0]
        if not self.connected:
            self.show_output("Not connected.")
        else:
            try:
                return func(*args, **kwargs)
            except APIError:
                self.show_output("ZooKeeper internal error.")
            except AuthFailedError:
                self.show_output("Authentication failed.")
            except NoAuthError:
                self.show_output("Not authenticated.")
            except BadVersionError:
                self.show_output("Bad version.")
            except ConnectionLoss:
                self.show_output("Connection loss.")
            except NotReadOnlyCallError:
                self.show_output("Not a read-only operation.")
            except BadArgumentsError:
                self.show_output("Bad arguments.")
            except SessionExpiredError:
                self.show_output("Session expired.")
            except UnimplementedError as ex:
                self.show_output("Not implemented by the server: %s." % str(ex))
            except ZookeeperError as ex:
                self.show_output("Unknown ZooKeeper error: %s" % str(ex))

    return wrapper
554224
def _request(self, method, uri, headers={}, body='', stream=False):
        
        response = None
        headers.setdefault('Accept',
                           'multipart/mixed, application/json, */*;q=0.5')

        if self._client._credentials:
            self._security_auth_headers(self._client._credentials.username,
                                        self._client._credentials.password,
                                        headers)

        try:
            self._connection.request(method, uri, body, headers)
            try:
                response = self._connection.getresponse(buffering=True)
            except TypeError:
                response = self._connection.getresponse()

            if stream:
                # The caller is responsible for fully reading the
                # response and closing it when streaming.
                response_body = response
            else:
                response_body = response.read()
        finally:
            if response and not stream:
                response.close()

        return response.status, response.msg, response_body
483851
function wrapCallback(pluginConfig, cb) {
	return (err, data) => {
		// Stop watchdog timers
		clearTimers();

		// If an error was thrown we'll report it to Sentry
		if (err && pluginConfig.captureErrors) {
			const Raven = pluginConfig.ravenClient;
			ravenInstalled && Raven.captureException(err, {}, () => {
				cb(err, data);
			});
		}
		else {
			cb(err, data);
		}
	};
}
19127
function wrapReturn(trace, clientState, hooks, rules){
  if (util.isFunction(trace.ret) && !trace.ret.__concurix_blacklisted) {
    wrapFunctions(trace.moduleName, trace.ret, -1, hooks, clientState, rules );
    trace.ret = wrap(trace.ret)
          .before(hooks.beforeHook)
          .after(hooks.afterHook)
          .state(clientState)
          .nameIfNeeded(trace.moduleName)
          .module(trace.moduleName)
          .getProxy();
  } else {
    wrapFunctions(trace.moduleName, trace.ret, -1, hooks, clientState, rules );
  }
}
650389
def get_request_body_chunk(self, content: bytes, closed: bool,
                               more_content: bool) -> Dict[str, Any]:
        '''
        
        '''
        return {
            'content': content,
            'closed': closed,
            'more_content': more_content
        }
668516
function wrappingFetch({ url, method, data }, optionsArg) {
    let requestStatus = createRequestStatus();
    // Here we are using destruct to filter properties we do not want to give to fetch.
    // CORS and isCORS are useless legacy code, xhrErrors is used only in error parsing
    // eslint-disable-next-line no-unused-vars
    let { CORS, isCORS, xhrErrors, ...config } = configGetter();
    const { noStringify, ...options } = optionsArg || {};
    const reqOptions = merge({ headers: {} }, config, options, { method, body: noStringify ? data : JSON.stringify(data) });
    //By default, add json content-type
    if (!reqOptions.noContentType && !reqOptions.headers['Content-Type']) {
        reqOptions.headers['Content-Type'] = 'application/json';
    }
    // Set the requesting as pending
    updateRequestStatus({ id: requestStatus.id, status: 'pending' });
    // Do the request
    return fetch(url, reqOptions)
        // Catch the possible TypeError from fetch
        .catch(error => {
            updateRequestStatus({ id: requestStatus.id, status: 'error' });
            return Promise.reject({ globalErrors: [error] });
        }).then(response => {
            updateRequestStatus({ id: requestStatus.id, status: response.ok ? 'success' : 'error' });
            const contentType = response.headers.get('content-type');
            return getResponseContent(response, reqOptions.dataType ? reqOptions.dataType : contentType && contentType.includes('application/json') ? 'json' : 'text');
        }).catch(data => {
            checkErrors(data, xhrErrors);
            return Promise.reject(data);
        });
}
304633
def wrap_session_request(wrapped, instance, args, kwargs):
    """"""
    method = kwargs.get('method') or args[0]
    url = kwargs.get('url') or args[1]

    blacklist_hostnames = execution_context.get_opencensus_attr(
        'blacklist_hostnames')
    parsed_url = urlparse(url)
    if parsed_url.port is None:
        dest_url = parsed_url.hostname
    else:
        dest_url = '{}:{}'.format(parsed_url.hostname, parsed_url.port)
    if utils.disable_tracing_hostname(dest_url, blacklist_hostnames):
        return wrapped(*args, **kwargs)

    _tracer = execution_context.get_opencensus_tracer()
    _span = _tracer.start_span()

    _span.name = '[requests]{}'.format(method)
    _span.span_kind = span_module.SpanKind.CLIENT

    try:
        tracer_headers = _tracer.propagator.to_headers(
            _tracer.span_context)
        kwargs.setdefault('headers', {}).update(
            tracer_headers)
    except Exception:  # pragma: NO COVER
        pass

    # Add the requests url to attributes
    _tracer.add_attribute_to_current_span(HTTP_URL, url)

    result = wrapped(*args, **kwargs)

    # Add the status code to attributes
    _tracer.add_attribute_to_current_span(
        HTTP_STATUS_CODE, str(result.status_code))

    _tracer.end_span()
    return result
579770
function asyncWrap (route) {
  return (req, res, next) => route(req, res, next).catch(next)
}