B2G/gecko/services/sync/modules/policies.js
/**
   * Handle HTTP response results or exceptions and set the appropriate
   * Status.* bits.
   */
Handle HTTP response results or exceptions and set the appropriate
Status.* bits.
Handle HTTP response results or exceptions and set the appropriate Status . * bits .
function checkServerError(resp) {
    switch (resp.status) {
      case 400:
        if (resp == RESPONSE_OVER_QUOTA) {
          Status.sync = OVER_QUOTA;
        }
        break;
      case 401:
        Weave.Service.logout();
        this._log.info("Got 401 response; resetting clusterURL.");
        Svc.Prefs.reset("clusterURL");
        let delay = 0;
        if (Svc.Prefs.get("lastSyncReassigned")) {
          this._log.warn("Last sync also failed for 401. Delaying next sync.");
          delay = MINIMUM_BACKOFF_INTERVAL;
        } else {
          this._log.debug("New mid-sync 401 failure. Making a note.");
          Svc.Prefs.set("lastSyncReassigned", true);
        }
        this._log.info("Attempting to schedule another sync.");
        SyncScheduler.scheduleNextSync(delay);
        break;
      case 500:
      case 502:
      case 503:
      case 504:
        Status.enforceBackoff = true;
        if (resp.status == 503 && resp.headers["retry-after"]) {
          if (Weave.Service.isLoggedIn) {
            Status.sync = SERVER_MAINTENANCE;
          } else {
            Status.login = SERVER_MAINTENANCE;
          }
          Svc.Obs.notify("weave:service:backoff:interval",
                         parseInt(resp.headers["retry-after"], 10));
        }
        break;
    }
    switch (resp.result) {
      case Cr.NS_ERROR_UNKNOWN_HOST:
      case Cr.NS_ERROR_CONNECTION_REFUSED:
      case Cr.NS_ERROR_NET_TIMEOUT:
      case Cr.NS_ERROR_NET_RESET:
      case Cr.NS_ERROR_NET_INTERRUPT:
      case Cr.NS_ERROR_PROXY_CONNECTION_REFUSED:
        if (Weave.Service.isLoggedIn) {
          Status.sync = LOGIN_FAILED_NETWORK_ERROR;
        } else {
          Status.login = LOGIN_FAILED_NETWORK_ERROR;
        }
        break;
    }
  }
function checkServerError ( resp ) { switch ( resp . status ) { case 400 : if ( resp == RESPONSE_OVER_QUOTA ) { Status . sync = OVER_QUOTA ; } break ; case 401 : Weave . Service . logout ( ) ; this . _log . info ( "Got 401 response; resetting clusterURL." ) ; Svc . Prefs . reset ( "clusterURL" ) ; let delay = 0 ; if ( Svc . Prefs . get ( "lastSyncReassigned" ) ) { this . _log . warn ( "Last sync also failed for 401. Delaying next sync." ) ; delay = MINIMUM_BACKOFF_INTERVAL ; } else { this . _log . debug ( "New mid-sync 401 failure. Making a note." ) ; Svc . Prefs . set ( "lastSyncReassigned" , true ) ; } this . _log . info ( "Attempting to schedule another sync." ) ; SyncScheduler . scheduleNextSync ( delay ) ; break ; case 500 : case 502 : case 503 : case 504 : Status . enforceBackoff = true ; if ( resp . status == 503 && resp . headers [ "retry-after" ] ) { if ( Weave . Service . isLoggedIn ) { Status . sync = SERVER_MAINTENANCE ; } else { Status . login = SERVER_MAINTENANCE ; } Svc . Obs . notify ( "weave:service:backoff:interval" , parseInt ( resp . headers [ "retry-after" ] , 10 ) ) ; } break ; } switch ( resp . result ) { case Cr . NS_ERROR_UNKNOWN_HOST : case Cr . NS_ERROR_CONNECTION_REFUSED : case Cr . NS_ERROR_NET_TIMEOUT : case Cr . NS_ERROR_NET_RESET : case Cr . NS_ERROR_NET_INTERRUPT : case Cr . NS_ERROR_PROXY_CONNECTION_REFUSED : if ( Weave . Service . isLoggedIn ) { Status . sync = LOGIN_FAILED_NETWORK_ERROR ; } else { Status . login = LOGIN_FAILED_NETWORK_ERROR ; } break ; } }
Handle HTTP response results or exceptions and set the appropriate
 Status.
Handle HTTP response results or exceptions and set the appropriate Status .
// We got a 401 in the middle of the previous sync, and we just got // another. Login must have succeeded in order for us to get here, so // the password should be correct. // This is likely to be an intermittent server issue, so back off and // give it time to recover. // The constant says it's about login, but in fact it just // indicates general network error.