REQUEST // 
FUNCTION: request( clbk )
Makes a request.

@param {Function} clbk - callback to invoke after receiving a response
773029
function request( next ) {
	/* jshint validthis: true */
	var self = this,
		body = '',
		req;

	this.req.opts.agent = agent;

	// TODO: record request headers
	// TODO: record request header length
	// TODO: record request body length

	req = http.request( this.req.opts, onResponse );
	req.on( 'error', onError );

	this.start = Date.now();
	this.timer = process.hrtime();

	if ( this.req.body ) {
		req.write( this.req.body );
	}
	req.end();

	cache[ this.rid ] = req;

	/**
	* FUNCTION: onConnect( response, socket, head )
	*	Callback invoked upon connecting to a server.
	*
	* @private
	* @param {Object} response - HTTP response object
	* @param {Socket} socket - TCP socket
	* @param {Object} head - HTTP response head
	*/
	function onConnect( response, socket, head ) {
		// Do something...
	}

	/**
	* FUNCTION: onResponse( response )
	*	Callback invoked upon receiving an HTTP response.
	*
	* @private
	* @param {Object} response - HTTP response object
	*/
	function onResponse( res ) {
		self.res.status = res.statusCode;
		self.res.headers = res.headers;

		// TODO: record headers length

		res.on( 'data', onData );
		res.on( 'end', onEnd );
	}

	/**
	* FUNCTION: onError( error )
	*	Callback invoked if an error is encountered while making a request.
	*
	* @private
	* @param {Error} error - error object
	*/
	function onError( error ) {
		self.req.error = error;
		if ( process.connected ) {
			// TODO: log (or not; serialize in output message?)
			console.error( process.pid, 'request', error );
		}
	}

	/**
	* FUNCTION: onData( chunk )
	*	Callback invoked after receiving a chunk of response data.
	*
	* @private
	* @param {Buffer} chunk - response data
	*/
	function onData( chunk ) {
		self.res.bytes += chunk.length;
		body += chunk.toString();
	}

	/**
	* FUNCTION: onEnd()
	*	Callback invoked after a response ends.
	*
	* @private
	*/
	function onEnd() {
		self.elapsed = process.hrtime( self.timer );
		self.end = Date.now();
		self.res.body = body;
		delete cache[ self.rid ];
		delete self.req.opts[ 'agent' ];
		next();
	}
}
647485
function makeRequest(method, auth, url, qs, data, cb) {		// eslint-disable-line max-params
	const options = {
		method: method,
		headers: {
			'Content-Type': 'application/json',
			'Authorization': auth
		},
		url: url, // for debugging set to: "https://httpbin.org/get"
		qs: qs
	}

	if(data) {
		options.body = JSON.stringify(data)
	}

	request(options, createResponseHandler(cb))
}
425182
function request(refs, opts, callback) {
  var url = fmt(format, endpoint, cache.user, cache.repo, refs);

  got.get(url, opts, function(err, res) {
    res = res ? JSON.parse(res) : {};
    if (res.ref === refs) {
      callback(null, true);
      return;
    }

    callback(null, false);
  });
}
549894
function(request, callback, response_middlewares) {
        var that = this;
        request.finalize(function(err, res) {
            if (err) callback(err, null);
            else that._callResponseMiddlewares(response_middlewares, res, callback);
        });
    }
1295839
function (options, callback) {
    var self = this,
        requestOptions = {
          path: _urlPrefix
    };

    if (typeof options === 'function') {
      callback = options;
      options = {};
    }

    self._request(requestOptions, function (err, body) {
      if (err) {
        return callback(err);
      }

      else if (!body || !body.loadBalancers) {
        return callback(new Error('Unexpected empty response'));
      }

      else {
        return callback(null, body.loadBalancers.map(function (loadBalancer) {
          return new lb.LoadBalancer(self, loadBalancer);
        }));
      }
    });
  }
1201797
function request(uri, opt, callback) {
    if (typeof opt === 'function') {
        callback = opt;
        opt = {};
    }
    return hyperquest(uri, opt, callback);
}
118819
function makeRequest(apiKey, path, opts, callback) {
    var 
        key,
        req,
        dataStr = '';
        
    if(callback === undefined) {
        throw 'No callback defined';
        return;
    }

    path = '/plus/v1/' + path + '?key=' + apiKey;
    for(key in opts) {
        path += '&' + key + '=' + opts[key];
    }

    req = https.request({
        host: 'www.googleapis.com',
        port: 443,
        path: path,
        method: 'GET'
    }, function(res) {
        res.on('data', function(data) {
            dataStr += data;
        });
        
        res.on('end', function() {
            if(opts.alt === undefined || opts.alt.toLowerCase() == 'json') {
                try {
                    callback(null, JSON.parse(dataStr));
                } catch(err) {
                    callback(null, dataStr);
                }
            }
            else {
                callback(null, dataStr);
            }
        });
        
        res.on('close', function () {
            res.emit('end');
        });
    });
    req.end();
    
    req.on('error', function(err) {
        callback(err);
    });

    return req;
}
469408
function (request, callback) {
            this._requests[request.id] = {
                request : request,
                cb : callback
            };

            // handle timeout
            ariaCoreIO.setTimeout(request.id, request.timeout, {
                fn : this.onAbort,
                scope : this,
                args : [request]
            });

            this._createIFrame(request);
            this._submitForm(request, callback);
        }
1037921
function _request(requestOptions, userOptions, successCallback, errorCallback) {
    var successCb = successCallback,
      errorCb = errorCallback,
      request;

    // This verification allows not to pass any options, and have callbacks in
    // its place. It also allows passing *null* if there is no success callback.
    if (Utils.isFunction(userOptions) || userOptions === null) {

      successCb = userOptions;
      errorCb = successCallback;

    } else if (Utils.isObject(userOptions)) {

      // If options is an object, merge it with the request options. Callbacks
      // can be included in this object or as separate parameters (same as
      // `EVT.api()`).
      requestOptions = Utils.extend(requestOptions, userOptions);

    }

    // Use current scope's API key to perform the request.
    requestOptions.authorization = this.scope.apiKey;

    // If parentScope is set to operator scope, use the operator API key.
    if (EVT.Operator && this.scope.parentScope instanceof EVT.Operator) {
      requestOptions.authorization = this.scope.parentScope.apiKey;

      // If we're working in application scope as an operator,
      // we need to send the application id as a parameter.
      if (this.scope instanceof EVT.App) {
        requestOptions.params = requestOptions.params || {};
        requestOptions.params.project = this.scope.project;
      }
    }

    // Actually make the request and handle its response, by forwarding to
    // the raw `EVT.api()` method.
    request = EVT.api(requestOptions, successCb, errorCb);

    return _handleResponse.call(this, request);
  }
994354
function Request (method, url) {
      var self = this
      Emitter.call(this)
      this._query = this._query || []
      this.method = method
      this.url = url
      this.header = {}
      this._header = {}
      this.on('end', function (){
        var err = null
        var res = null

        try {
          res = new Response(self)
        } catch(e) {
          err = new Error('Parser is unable to parse the response')
          err.parse = true
          err.original = e
        }

        self.callback(err, res)
      })
    }
1159170
function sendRequest()
  {
    // snow-28673 For s3/blob requests, did not append requestId
    var url = (options.appendRequestId === false) ?
      options.url :
      Util.url.appendParam(options.url, 'httpRequestId', httpRequestId);

    Logger.getInstance().trace(url);

    // build the basic request options
    var requestOptions =
    {
      method             : options.method,
      url                : url,
      headers            : headers,
      gzip               : options.gzip,
      json               : json,
      body               : body,
      timeout            : options.timeout ||
                           this._connectionConfig.getTimeout(),
      requestOCSP        : true,
      rejectUnauthorized : true
    };

    // add the agent and proxy options
    var agentAndProxyOptions = this.getAgentAndProxyOptions(
        url, this._connectionConfig.getProxy());
    requestOptions = Util.apply(requestOptions, agentAndProxyOptions);

    // issue the request
    request = this.getRequestModule()(
        requestOptions, function(err, response, body)
        {
          // if a callback has been specified, normalize the
          // response before passing it to the callback
          if (Util.isFunction(options.callback))
          {
            options.callback(err, normalizeResponse(response), body);
          }
        });
  }
429193
def _request(request, request_fallback=None):
        '''  '''
        # Use lambdas to avoid evaluating bottle.request.* which may throw an Error
        all_dicts = [
            lambda: request.json,
            lambda: request.forms,
            lambda: request.query,
            lambda: request.files,
            #lambda: request.POST,
            lambda: request_fallback
        ]
        request_dict = dict()
        for req_dict_ in all_dicts:
            try:
                req_dict = req_dict_()
            except KeyError:
                continue
            if req_dict is not None and hasattr(req_dict, 'items'):
                for req_key, req_val in req_dict.items():
                    request_dict[req_key] = req_val
        return request_dict
576483
function requestHandler (method) {
  return function (req, res, next) {
    method.call(this, req, responseHandler(res, next));
  }.bind(this);
}
1368206
function _makeRequest (request_query, cb) {
  https.get(request_query, function(res) {
      var data = [];
      res
      .on('data', function(chunk) { data.push(chunk); })
      .on('end', function() {
          var dataBuff = data.join('').trim();
          var result;
          try {
            result = JSON.parse(dataBuff);
          } catch (exp) {
            result = {'status_code': 500, 'status_text': 'JSON Parse Failed'};
          }
          cb(null, result);
      });
  })
  .on('error', function(e) {
      cb(e);
  });
}
692100
function Request(opts){
  this.method = opts.method || 'GET';
  this.uri = opts.uri;
  this.xd = !!opts.xd;
  this.async = false !== opts.async;
  this.data = undefined != opts.data ? opts.data : null;
  this.create();
}
986262
function request(server, config, hooks, keys, request, callback) {
    const start = Date.now();

    if (typeof request === 'function' && typeof callback !== 'function') {
        callback = request;
        request = {};
    }

    // handle argument variations and get Request instance
    const args = Array.from(arguments).slice(4).filter(v => v !== undefined);
    const req = (function() {
        const length = args.length;
        if (length === 0) {
            return new Request(server, keys, config.rejectable);

        } else if (length === 1 && typeof args[0] === 'function') {
            callback = args[0];
            return new Request(server, keys, config.rejectable);

        } else {
            return new Request(server, keys, config.rejectable, request);
        }
    })();

    // event log aggregation
    const queue = config.logs ? [] : null;
    if (queue) req.on('log', event => queue.push(event));

    // if logging enabled then produce the log when the request is fulfilled or rejected
    if (queue) {
        const log = function(state) {
            const events = queue.map((event, index) => {
                const seconds = util.seconds(event.timestamp - (index > 0 ? queue[index - 1].timestamp : start));
                return '[+' + seconds + 's] ' + event.category + ':' + event.type + ' ' + event.data;
            });
            console.log(state.statusCode + ' ' + req.method + ' ' + req.url +
                (state.statusCode === 302 ? '\n  Redirect To: ' + state.headers['location']  : '') +
                '\n  ID: ' + req.id +
                '\n  Start: ' + new Date(start).toISOString() +
                '\n  Duration: ' + prettyPrint.seconds(Date.now() - start) +
                '\n  Events:\n    ' +
                events.join('\n    '));
        };
        req.then(log, () => log(req.res.state));
    }

    // copy hooks into request
    req.log('initialized');
    Object.keys(hooks).forEach(type => {
        hooks[type].forEach(d => {
            req.hook(type, d.weight, d.hook)
        });
    });
    req.log('hooks applied');

    // is using a callback paradigm then execute the callback
    if (typeof callback === 'function') req.then(state => callback(null, state), err => callback(err, req.res.state));

    return req;
}
948317
function (_callback)
    {
        if (_callback) {
            _callback = _callback.bind(this._conn);
        } else {
            _callback = this._conn._connect_cb.bind(this._conn);
        }
        var body = this._buildBody();
        this._requests.push(
                new Strophe.Request(body.tree(),
                    this._onRequestStateChange.bind(
                        this, _callback.bind(this._conn)),
                    body.tree().getAttribute("rid")));
        this._throttledRequestHandler();
    }