lib/resolvers/http.js
function get (u, httpOptions) {
  return new Promise(function (resolve, reject) {
    // console.log('GET', u.href);

    var protocol = u.protocol === "https:" ? https : http;
    var req = protocol.get({
      hostname: u.hostname,
      port: u.port,
      path: u.path,
      auth: u.auth,
      protocol: u.protocol,
      headers: httpOptions.headers || {},
      withCredentials: httpOptions.withCredentials
    });

    if (typeof req.setTimeout === "function") {
      req.setTimeout(httpOptions.timeout);
    }

    req.on("timeout", function () {
      req.abort();
    });

    req.on("error", reject);

    req.once("response", function (res) {
      res.body = new Buffer(0);

      res.on("data", function (data) {
        res.body = Buffer.concat([res.body, new Buffer(data)]);
      });

      res.on("error", reject);

      res.on("end", function () {
        resolve(res);
      });
    });
  });
}
function get (u, httpOptions) {
  return new Promise(function (resolve, reject) {
    // console.log('GET', u.href);

    var protocol = u.protocol === "https:" ? https : http;
    var req = protocol.get({
      hostname: u.hostname,
      port: u.port,
      path: u.path,
      auth: u.auth,
      protocol: u.protocol,
      headers: httpOptions.headers || {},
      withCredentials: httpOptions.withCredentials
    });

    if (typeof req.setTimeout === "function") {
      req.setTimeout(httpOptions.timeout);
    }

    req.on("timeout", function () {
      req.abort();
    });

    req.on("error", reject);

    req.once("response", function (res) {
      res.body = new Buffer(0);

      res.on("data", function (data) {
        res.body = Buffer.concat([res.body, new Buffer(data)]);
      });

      res.on("error", reject);

      res.on("end", function () {
        resolve(res);
      });
    });
  });
}
function get ( u , httpOptions ) { return new Promise ( function ( resolve , reject ) { // console.log('GET', u.href); var protocol = u . protocol === "https:" ? https : http ; var req = protocol . get ( { hostname : u . hostname , port : u . port , path : u . path , auth : u . auth , protocol : u . protocol , headers : httpOptions . headers || { } , withCredentials : httpOptions . withCredentials } ) ; if ( typeof req . setTimeout === "function" ) { req . setTimeout ( httpOptions . timeout ) ; } req . on ( "timeout" , function ( ) { req . abort ( ) ; } ) ; req . on ( "error" , reject ) ; req . once ( "response" , function ( res ) { res . body = new Buffer ( 0 ) ; res . on ( "data" , function ( data ) { res . body = Buffer . concat ( [ res . body , new Buffer ( data ) ] ) ; } ) ; res . on ( "error" , reject ) ; res . on ( "end" , function ( ) { resolve ( res ) ; } ) ; } ) ; } ) ; }
Sends an HTTP GET request.

@param {Url} u - A parsed {@link Url} object
@param {object} httpOptions - The `options.resolve.http` object

@returns {Promise<Response>}
The promise resolves with the HTTP Response object.
Sends an HTTP GET request .