Bug 966560: fix bugs with time skew fix in bug 957863, r=jedp
☠☠ backed out by 46a75174aeb9 ☠ ☠
authorChris Karlof <ckarlof@mozilla.com>
Fri, 31 Jan 2014 16:43:36 -0800
changeset 182427 cc1bac015920d92547436c05b5c8177d5cb7d137
parent 182426 a3e013d80c0e57475c0f6bd4d954233a0916a228
child 182428 a6805f2f89143686778c2834ed8ef40c988c37dc
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjedp
bugs966560, 957863
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 966560: fix bugs with time skew fix in bug 957863, r=jedp
services/common/hawk.js
services/common/rest.js
services/fxaccounts/FxAccounts.jsm
services/sync/modules/browserid_identity.js
--- a/services/common/hawk.js
+++ b/services/common/hawk.js
@@ -189,13 +189,17 @@ HawkClient.prototype = {
     };
 
     let extra = {
       now: this.now(),
       localtimeOffsetMsec: this.localtimeOffsetMsec,
     };
 
     let request = new HAWKAuthenticatedRESTRequest(uri, credentials, extra);
-    request[method](payloadObj, onComplete);
+    if (method == "post" || method == "put") {
+      request[method](payloadObj, onComplete);
+    } else {
+      request[method](onComplete);
+    }
 
     return deferred.promise;
   }
 }
--- a/services/common/rest.js
+++ b/services/common/rest.js
@@ -758,26 +758,32 @@ this.HAWKAuthenticatedRESTRequest =
   this.now = extra.now || Date.now();
   this.localtimeOffsetMsec = extra.localtimeOffsetMsec || 0;
   this._log.trace("local time, offset: " + this.now + ", " + (this.localtimeOffsetMsec));
 };
 HAWKAuthenticatedRESTRequest.prototype = {
   __proto__: RESTRequest.prototype,
 
   dispatch: function dispatch(method, data, onComplete, onProgress) {
+    let contentType = "text/plain";
+    if (method == "POST" || method == "PUT") {
+      contentType = "application/json";
+    }
     if (this.credentials) {
       let options = {
         now: this.now,
         localtimeOffsetMsec: this.localtimeOffsetMsec,
         credentials: this.credentials,
         payload: data && JSON.stringify(data) || "",
-        contentType: "application/json; charset=utf-8",
+        contentType: contentType,
       };
       let header = CryptoUtils.computeHAWK(this.uri, method, options);
       this.setHeader("Authorization", header.field);
       this._log.trace("hawk auth header: " + header.field);
     }
 
+    this.setHeader("Content-Type", contentType);
+
     return RESTRequest.prototype.dispatch.call(
       this, method, data, onComplete, onProgress
     );
   }
 };
--- a/services/fxaccounts/FxAccounts.jsm
+++ b/services/fxaccounts/FxAccounts.jsm
@@ -615,16 +615,23 @@ this.FxAccounts.prototype = Object.freez
   getKeys: function() {
     return internal.getKeys();
   },
 
   whenVerified: function(userData) {
     return internal.whenVerified(userData);
   },
 
+  now: function() {
+    return internal.now();
+  },
+
+  get localtimeOffsetMsec() {
+    return internal.localtimeOffsetMsec;
+  },
 
   /**
    * Sign the current user out.
    *
    * @return Promise
    *         The promise is rejected if a storage error occurs.
    */
   signOut: function signOut() {
--- a/services/sync/modules/browserid_identity.js
+++ b/services/sync/modules/browserid_identity.js
@@ -189,21 +189,21 @@ this.BrowserIDManager.prototype = {
   _computeXClientState: function(kBbytes) {
     return CommonUtils.bytesAsHex(this._sha256(kBbytes).slice(0, 16), false);
   },
 
   /**
    * Provide override point for testing token expiration.
    */
   _now: function() {
-    return this._fxaService.internal.now()
+    return this._fxaService.now()
   },
 
   get _localtimeOffsetMsec() {
-    return this._fxaService.internal.localtimeOffsetMsec;
+    return this._fxaService.localtimeOffsetMsec;
   },
 
   get account() {
     return this._account;
   },
 
   /**
    * Sets the active account name.