B2G/gecko/services/aitc/modules/client.js
/**
   * Try PUT for an app on the server and determine if we should retry
   * if it fails.
   */
Try PUT for an app on the server and determine if we should retry
if it fails.
Try PUT for an app on the server and determine if we should retry if it fails .
function _putApp(app, cb) {
    if (!this._isRequestAllowed()) {
      let err = new Error("Backoff in effect, aborting PUT");
      err.processed = false;
      cb(err, null);
      return;
    }
    let uri = this._makeAppURI(app.origin);
    let req = new TokenAuthenticatedRESTRequest(uri, this.token);
    req.timeout = this._timeout;
    req.setHeader("Content-Type", "application/json");
    if (app.modifiedAt) {
      req.setHeader("X-If-Unmodified-Since", "" + app.modified);
    }
    let self = this;
    this._log.info("Trying to _putApp to " + uri);
    req.put(JSON.stringify(app), function _putAppCb(err) {
      self._processPutApp(err, cb, req);
    });
  }
function _putApp ( app , cb ) { if ( ! this . _isRequestAllowed ( ) ) { let err = new Error ( "Backoff in effect, aborting PUT" ) ; err . processed = false ; cb ( err , null ) ; return ; } let uri = this . _makeAppURI ( app . origin ) ; let req = new TokenAuthenticatedRESTRequest ( uri , this . token ) ; req . timeout = this . _timeout ; req . setHeader ( "Content-Type" , "application/json" ) ; if ( app . modifiedAt ) { req . setHeader ( "X-If-Unmodified-Since" , "" + app . modified ) ; } let self = this ; this . _log . info ( "Trying to _putApp to " + uri ) ; req . put ( JSON . stringify ( app ) , function _putAppCb ( err ) { self . _processPutApp ( err , cb , req ) ; } ) ; }
Try PUT for an app on the server and determine if we should retry
 if it fails.
Try PUT for an app on the server and determine if we should retry if it fails .
// PUT requests may qualify as the "minimum number of additional requests // required to maintain consistency of their stored data". However, it's // better to keep server load low, even if it means user's apps won't // reach their other devices during the early days of AITC. We should // revisit this when we have a better of idea of server load curves.