Fix Backoff and Retry-After header parsing
This commit is contained in:
parent
79d7c15d4f
commit
5ddbe433b9
2 changed files with 4 additions and 4 deletions
|
@ -820,7 +820,7 @@ Zotero.Sync.APIClient.prototype = {
|
|||
|
||||
_checkBackoff: function (xmlhttp) {
|
||||
var backoff = xmlhttp.getResponseHeader("Backoff");
|
||||
if (backoff && Number.isInteger(backoff)) {
|
||||
if (backoff && parseInt(backoff) == backoff) {
|
||||
// TODO: Update status?
|
||||
this.caller.pause(backoff * 1000);
|
||||
}
|
||||
|
@ -831,7 +831,7 @@ Zotero.Sync.APIClient.prototype = {
|
|||
var retryAfter = xmlhttp.getResponseHeader("Retry-After");
|
||||
var delay;
|
||||
if (!retryAfter) return false;
|
||||
if (!Number.isInteger(retryAfter)) {
|
||||
if (parseInt(retryAfter) != retryAfter) {
|
||||
Zotero.logError(`Invalid Retry-After delay ${retryAfter}`);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ describe("Zotero.Sync.APIClient", function () {
|
|||
req.respond(
|
||||
503,
|
||||
{
|
||||
"Retry-After": 5
|
||||
"Retry-After": "5"
|
||||
},
|
||||
""
|
||||
);
|
||||
|
@ -183,7 +183,7 @@ describe("Zotero.Sync.APIClient", function () {
|
|||
req.respond(
|
||||
503,
|
||||
{
|
||||
"Retry-After": 10
|
||||
"Retry-After": "10"
|
||||
},
|
||||
""
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue