lib/download.js
function(url, callback) {
    if (this.cache[url]) {
      return callback && callback(null, this.cache[url]);
    }

    debug('GET ' + url);
    var protocol = this._getProtocol(url);
    protocol.get(url, function(res) {
      if (res.statusCode !== 200) {
        return callback && callback(
          new Error('Bad status ' + res.statusCode + ' for ' + url));
      }

      res.setEncoding('utf-8');
      var result = '';
      res.on('data', function(data) {
        result += data;
      });
      res.on('end', function() {
        this.cache[url] = result;
        return callback && callback(null, result);
      }.bind(this));
    }.bind(this)).on('error', function(e) {
      return callback && callback(e);
    });
  }
function(url, callback) {
    if (this.cache[url]) {
      return callback && callback(null, this.cache[url]);
    }

    debug('GET ' + url);
    var protocol = this._getProtocol(url);
    protocol.get(url, function(res) {
      if (res.statusCode !== 200) {
        return callback && callback(
          new Error('Bad status ' + res.statusCode + ' for ' + url));
      }

      res.setEncoding('utf-8');
      var result = '';
      res.on('data', function(data) {
        result += data;
      });
      res.on('end', function() {
        this.cache[url] = result;
        return callback && callback(null, result);
      }.bind(this));
    }.bind(this)).on('error', function(e) {
      return callback && callback(e);
    });
  }
function ( url , callback ) { if ( this . cache [ url ] ) { return callback && callback ( null , this . cache [ url ] ) ; } debug ( 'GET ' + url ) ; var protocol = this . _getProtocol ( url ) ; protocol . get ( url , function ( res ) { if ( res . statusCode !== 200 ) { return callback && callback ( new Error ( 'Bad status ' + res . statusCode + ' for ' + url ) ) ; } res . setEncoding ( 'utf-8' ) ; var result = '' ; res . on ( 'data' , function ( data ) { result += data ; } ) ; res . on ( 'end' , function ( ) { this . cache [ url ] = result ; return callback && callback ( null , result ) ; } . bind ( this ) ) ; } . bind ( this ) ) . on ( 'error' , function ( e ) { return callback && callback ( e ) ; } ) ; }
Download http response to memory.

@param {string} url to fetch.
@param {Function} callback invoke when done.
Download http response to memory .