Issue request to hover api.

@param {String} method
@param {String} path
@param {Object} [body]
@param {Function} cb
@api private
514646
function _hoverApiRequest (method, path, body, cb) {
        // Check body provided
        if (typeof body === 'function') {
            cb = body;
            body = null;
        }

        // Default options
        var options = {
            method: method,
            uri: baseUrl + path
        };

        // Add body if provided
        if (body) options.body = body;

        // Issue request
        r(options, _rCallback(function (err, data) {
            if (err) return cb(err);

            // Pull out property name
            var key = _.without(_.keys(data), 'succeeded');
            cb(null, data[key]);
        }));
    }
260284
function(header, path, method, transport) {
      transport = transport || 'http';
      if (transport !== 'http' && transport !== 'ws') {
        throw new CError('unknown transport').log();
      }
      var plain = true,
          self = this;
      method = method || 'GET';
      // prepare request
      if (!this.request || this.path !== path || this.method !== method) {
        var url = util.format('%s%s', this.urlBase, path);
        if (transport === 'http') {
          this.request = agent(method, url);
          // set timeout for request
          if (this.requestTimeout && this.requestTimeout > 0) {
            this.request.timeout(this.requestTimeout);
          }
          // set content type
          this.request.type('json');
        } else {
          var ws = getWebsocketPlugin();
          if (!ws) {
            throw new CError('websocket plugin not loaded');
          }
          this.request = ws.wsclient.primusagent(method, url, {
            timeout: this.requestTimeout
          });
        }
      }
      if (!this.request) {
        throw new CError('no request available').log();
      }
      // set headers
      if (header) {
        this.headers[authHeaderKey] = header.encode();
        _.each(this.headers, function(value, key) {
          self.request.set(key, value);
        });
        plain = (header.getMode() === 'auth-plain');
      }
      // compose query if required
      if (this._pendingQuery) {
        _.forEach(this._pendingQuery, function(value) {
          if (plain || self._noAuthHeader) {
            if (!_.isObject(value)) {
              throw new CError('wrong query format').log();
            }
            self.request.query(value);
          } else {
            // encrypt query in Base64url
            if (!_.isObject(value)) {
              throw new CError('wrong query format').log();
            }
            _.forEach(value, function(item, property) {
              value[property] = header.encoder.encryptAes(item.toString(), header.getSecret(), 'url');
            });
            self.request.query(value);
          }
        });
      }
      // compose body if required
      if (this._pendingContent) {
        var content = {},
            _content = {};
        if (plain || this._noAuthHeader) {
          _.forEach(this._pendingContent, function(value) {
            if (!_.isObject(value)) {
              throw new CError('wrong body format').log();
            }
            self.request.send(value);
          });
          log.info('%s on request -> write plaintext body', app.name);
        } else {
          if (!header) {
            throw new CError('missing header').log();
          }
          _.forEach(this._pendingContent, function(value) {
            if (!_.isObject(value)) {
              throw new CError('wrong body format').log();
            }
            _.extend(_content, value);
          });
          content[my.config.encryptedBodyName] = header.cryptContent(_content);
          // sign the body
          if (my.config.signBody) {
            content[my.config.encryptedSignatureName] = header.generateSignature(_content);
          }
          log.info('%s on request -> write encrypted body', app.name);
          self.request.send(content);
        }
      }
    }
1041838
function request( opts, clbk ) {
	var body;
	var req;
	var res;
	var err;
	var r;

	// debug( 'Query options: %s', JSON.stringify( opts ) );

	if ( RE.test( opts.protocol ) ) {
		req = https.request;
	} else {
		req = http.request;
	}
	body = '';
	r = req( opts, onResponse );
	r.on( 'error', onError );
	r.end();

	/**
	* FUNCTION: onError( error )
	*	Event listener invoked after encountering an error.
	*
	* @private
	* @param {Error} error - error object
	* @returns {Void}
	*/
	function onError( error ) {
		debug( 'Error encountered while querying endpoint: %s', error.message );
		if ( error instanceof Error ) {
			err = {
				'status': 500,
				'message': 'Request error: ' + error.message
			};
			return clbk( err );
		}
		return clbk( error, res, body );
	} // end FUNCTION onError()

	/**
	* FUNCTION: onResponse( response )
	*	Callback invoked after receiving an HTTP response.
	*
	* @private
	* @param {Object} response - HTTP response object
	* @returns {Void}
	*/
	function onResponse( response ) {
		res = response;
		if ( res.statusCode !== 200 ) {
			err = {
				'status': res.statusCode,
				'message': ''
			};
		}
		debug( 'Received a response from query endpoint.' );
		debug( 'Response status: %s.', res.statusCode );

		debug( 'Response headers: %s', JSON.stringify( res.headers ) );

		res.setEncoding( 'utf8' );
		res.on( 'data', onData );
		res.on( 'end', onEnd );
	} // end FUNCTION onResponse()

	/**
	* FUNCTION: onData( chunk )
	*	Event listener invoked upon receiving response data.
	*
	* @private
	* @param {String} chunk - data chunk
	* @returns {Void}
	*/
	function onData( chunk ) {
		body += chunk;
	} // end FUNCTION onData()

	/**
	* FUNCTION: onEnd()
	*	Event listener invoked upon a response end.
	*
	* @private
	* @returns {Void}
	*/
	function onEnd() {
		var data;
		if ( err ) {
			err.message = body;
			return onError( err );
		}
		// debug( 'Response body: %s', body );

		data = parse( body );
		if ( data instanceof Error ) {
			err = {
				'status': 502,
				'message': 'unable to parse endpoint response data as JSON: ' + data.message
			};
			return onError( err );
		}
		clbk( null, res, data );
	} // end FUNCTION onEnd()
}
838545
function request (method, url) {
  // callback
      if ('function' === typeof url) {
        return new Request('GET', method).end(url)
      }

  // url first
      if (1 === arguments.length) {
        return new Request('GET', method)
      }

      return new Request(method, url)
    }
1283227
def request(method, path, options, raw=false)
      # identify our request
      # @see: http://docs.disqus.com/help/52/
      options ||= {}
      options.merge!(:api_secret => self.api_secret) unless options.has_key?(:api_secret)
      response = connection(raw).send(method) do |request|
        case method
        when :get
          request.url(formatted_path(path), options)
        when :post
          request.path = formatted_path(path)
          request.body = options unless options.empty?
        end
      end
      raw ? response : response.body
    end
1095661
def do_request(method, path, obj = nil, options = {})
      # hatt clients pass in path possibly including query params.
      # Faraday needs the query and path seperately.
      parsed_uri = URI.parse make_path(path)
      # faraday needs the request params as a hash.
      # this turns out to be non-trivial
      query_hash = if parsed_uri.query
                     cgi_hash = CGI.parse(parsed_uri.query)
                     # this next line accounts for one param having multiple values
                     cgi_hash.each_with_object({}) { |(k, v), h| h[k] = v[1] ? v : v.first; }
                   end

      req_headers = make_headers(options)

      body = if options[:form]
               URI.encode_www_form obj
             else
               jsonify(obj)
      end


      log_request(method, parsed_uri, query_hash, req_headers, body)

      # doing it this way avoids problem with OPTIONS method: https://github.com/lostisland/faraday/issues/305
      response = nil
      metrics_obj = { method: method, service: @name, path: parsed_uri.path }
      ActiveSupport::Notifications.instrument('request.hatt', metrics_obj) do
        response = @faraday_connection.run_request(method, nil, nil, nil) do |req|
          req.path = parsed_uri.path
          req.params = metrics_obj[:params] = query_hash if query_hash

          req.headers = req_headers
          req.body = body
          req.options[:timeout] = options.fetch(:timeout, @default_timeout)
        end
        metrics_obj[:response] = response
      end

      logger.info "Request status: (#{response.status}) #{@name}: #{method.to_s.upcase} #{path}"
      @last_request = {
        method: method,
        path: parsed_uri.path,
        query: parsed_uri.query,
        headers: req_headers,
        body: body
      }
      @last_response = response

      response_obj = objectify response.body

      log_response(response, response_obj)

      raise RequestException.new(nil, response) unless response.status >= 200 && response.status < 300

      response_obj
    end
907688
function(method, view) {
    return function (err) {
      if (err) {
        err.reason = 'Template#handle' + method + ': ' + view.path;
        return err;
      }
    };
  }
93131
function(p, cb)
{
  //Get the status of the path
  return fs.stat(p, function(error, stat)
  {
    //Check the error
    if(error)
    {
      //Check the error code
      if(error.code !== 'ENOENT')
      {
        //Do the callback with the error
        return cb(error, false, stat);
      }
      else
      {
        //Do the callback without error
        return cb(null, false, stat);
      }
    }

    //Do the callback with the stat
    return cb(null, true, stat);
  });
}
1147977
function(method, path, data) {
        const pendingReq = new ExpectedRequest(method, path, data);
        this.expectedRequests.push(pendingReq);
        return pendingReq;
    }
506454
def request(method, path, options)
      response = connection.send(method) do |request|
        case method
        when :get
          request.url(path, options)
        when :post
          request.path = path
          request.body = options unless options.empty?
        else
          raise Error.new("Unhandled request method #{method}")
        end
      end
      return response.body
    end
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)
      })
    }
1041205
function onProcCall(method, path, args) {
    let re;
    switch (method) {
    case 'GET':
        if (path === '') { // Request for members
            return listKeys(args);
        }
        re = localStorage.getItem(path);
        return (re == null ? {errors: [{error: 'No such path:'+path}]} : re);
    case 'POST':
    case 'PUT':
        try {
            localStorage.setItem(path, args);
            pi.server.publish(path, args); // PubSub
            return {success: true};
        } catch (e) {
            return {errors: [{error: 'Data should be in JSON format.'}]};
        }
    case 'DELETE':
        if (path == '') localStorage.clear();
        else localStorage.removeItem(path);
        pi.server.publish(path, {}); // PubSub
        return {success: true};
    default:
        return {errors: [{error: `The specified method ${method} is not implemented in admin plugin.`}]}; // eslint-disable-line max-len
    }
}
133348
private function routeLoader($method, $path, $cb)
    {
        // We build the original path based on the application loader
        $path = $this->config['app.root'].$this->prefix.$path;

        // We define the current route and current method
        $this->current = ['path' => $path, 'method' => $method];

        // We add the new route
        $route = new Route($path, $cb);

        $route->middleware($this->middlewares);

        $this->routes[$method][] = $route;

        $route->middleware('trim');

        if (in_array($method, ['POST', 'DELETE', 'PUT'])) {
            $route->middleware('csrf');
        }

        return $route;
    }
860481
function RouteRule_parseRequest(method, url) {

        var matches,
            route,
            key,
            result = [],
            escape = [],
            params = {},
            current;
        //match pathname
        matches = this.match(this.pattern, this.trim(url.pathname, '/'));


        if (!matches.length || !this.checkMethod(method)) {
            return false;
        }
        params = url.query;


        for (key in params) {
            current = this.find(matches, key);
            if (!current || current.value === '') {
                matches.push({
                    key: key,
                    value: params[key]
                });
            }
        }

        matches.forEach(function (item) {
            var current = this.find(this.routeParams, item.key);
            if (current) {
                escape.push({
                    key: '<' + current.key + '>',
                    value: item.value
                });
                delete params[item.name];
            } else if (this.find(this.paramRules, item.key)) {
                params[item.key] = item.value;
            }
        }.bind(this));


        if (this.routeParams.length) {
            route = this.escape(this.route, escape);
        } else {
            route = this.route;
        }

        result.push(route);
        result.push(params);

        return result;
    }
1233029
function(path, callbackSuccess, callbackError) {
  var xhr = new XMLHttpRequest();
  xhr.onreadystatechange = function() {
    if (xhr.readyState === 4) {
      if (xhr.status >= 200 && xhr.status < 300) {
        callbackSuccess(xhr.responseText);
      } else {
        callbackError();
      }
    }
  };
  xhr.open('GET', path, false);
  try {
    xhr.send();
  } catch (e) {
    callbackError();
  }
}
1324816
function get(path, cb) {
        getAgent((agent) => { http.get({ host: host, port: port, path: path, agent: agent}, (response) => {
            var body = ''; response.on('data', (d) => { body += d; });
            response.on('end', (err) => { if(cb) cb(body); });
        }).on('error', function(error) {
            log(`Error on GET ${path} ${error.message}`)
            if (cb) cb('');
        }) });
    }
1101866
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 res = new Response(self);
    if ('HEAD' == method) res.text = null;
    self.callback(null, res);
  });
}