lib/imagine/source_downloader.js
function () {
    // Create request options from parsed source URL
    var options = url.parse(this.source, false);

    // Add on some defaults
    extend(options, {
      method: 'get',
      headers: {
        host: options.host,
        accept: 'image/*'
      }
    });

    // Determine https/http from source URL
    var library = options.protocol === 'https:' ? https : http;

    // Setup the request and its event binds
    this.request = library.request(options);
    this.request.on('response', this.onResponse.bind(this));
    this.request.on('error', this.onError.bind(this));
    this.request.setTimeout(5000, this.onTimeout.bind(this));

    // Start the download
    this.startTime = new Date().getTime();
    this.request.end();
  }
function () {
    // Create request options from parsed source URL
    var options = url.parse(this.source, false);

    // Add on some defaults
    extend(options, {
      method: 'get',
      headers: {
        host: options.host,
        accept: 'image/*'
      }
    });

    // Determine https/http from source URL
    var library = options.protocol === 'https:' ? https : http;

    // Setup the request and its event binds
    this.request = library.request(options);
    this.request.on('response', this.onResponse.bind(this));
    this.request.on('error', this.onError.bind(this));
    this.request.setTimeout(5000, this.onTimeout.bind(this));

    // Start the download
    this.startTime = new Date().getTime();
    this.request.end();
  }
function ( ) { // Create request options from parsed source URL var options = url . parse ( this . source , false ) ; // Add on some defaults extend ( options , { method : 'get' , headers : { host : options . host , accept : 'image/*' } } ) ; // Determine https/http from source URL var library = options . protocol === 'https:' ? https : http ; // Setup the request and its event binds this . request = library . request ( options ) ; this . request . on ( 'response' , this . onResponse . bind ( this ) ) ; this . request . on ( 'error' , this . onError . bind ( this ) ) ; this . request . setTimeout ( 5000 , this . onTimeout . bind ( this ) ) ; // Start the download this . startTime = new Date ( ) . getTime ( ) ; this . request . end ( ) ; }
Simply start the request when we're ready to go
Simply start the request when we re ready to go