B2G/gecko/services/aitc/modules/storage.js
/**
   * Fetch a manifest from given URL. No retries are made on failure. We'll
   * timeout after 20 seconds.
   */
Fetch a manifest from given URL. No retries are made on failure. We'll
timeout after 20 seconds.
Fetch a manifest from given URL . No retries are made on failure . We ' ll timeout after 20 seconds .
function _getManifest(url, callback) {
    let req = new RESTRequest(url);
    req.timeout = 20;
    let self = this;
    req.get(function(error) {
      if (error) {
        callback(error, null);
        return;
      }
      if (!req.response.success) {
        callback(new Error("Non-200 while fetching manifest"), null);
        return;
      }
      let err = null;
      let manifest = null;
      try {
        manifest = JSON.parse(req.response.body);
        if (!manifest.name) {
          self._log.warn(
            "_getManifest got invalid manifest: " + req.response.body
          );
          err = new Error("Invalid manifest fetched");
        }
      } catch (e) {
        self._log.warn(
          "_getManifest got invalid JSON response: " + req.response.body
        );
        err = new Error("Invalid manifest fetched");
      }
      callback(err, manifest);
    });
  }
function _getManifest ( url , callback ) { let req = new RESTRequest ( url ) ; req . timeout = 20 ; let self = this ; req . get ( function ( error ) { if ( error ) { callback ( error , null ) ; return ; } if ( ! req . response . success ) { callback ( new Error ( "Non-200 while fetching manifest" ) , null ) ; return ; } let err = null ; let manifest = null ; try { manifest = JSON . parse ( req . response . body ) ; if ( ! manifest . name ) { self . _log . warn ( "_getManifest got invalid manifest: " + req . response . body ) ; err = new Error ( "Invalid manifest fetched" ) ; } } catch ( e ) { self . _log . warn ( "_getManifest got invalid JSON response: " + req . response . body ) ; err = new Error ( "Invalid manifest fetched" ) ; } callback ( err , manifest ) ; } ) ; }
Fetch a manifest from given URL.
Fetch a manifest from given URL .