Created
March 28, 2012 23:42
-
-
Save rnewman/2231561 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Components.utils.import("resource://services-sync/main.js"); | |
Components.utils.import("resource://services-sync/engines/clients.js"); | |
Components.utils.import("resource://services-sync/resource.js"); | |
function getClient() { | |
let r = new Resource(Weave.Service.storageURL + "clients/" + Clients.localID); | |
return r.get(); | |
} | |
let ts = null; | |
function tryUpload(resp) { | |
let p = new Resource(Weave.Service.storageURL + "clients/" + Clients.localID); | |
p.setHeader("X-If-Unmodified-Since", ts); | |
let out = p.put(resp); | |
if (out != out.headers["x-weave-timestamp"]) { | |
throw "NOOO: " + out + " != " + out.headers["x-weave-timestamp"]; | |
} | |
ts = out; | |
return out; | |
} | |
let r = getClient(); | |
ts = r.headers["x-weave-timestamp"] | |
for (let i = 0; i < 10; ++i) { | |
console.log(i); | |
tryUpload(r); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment