Don't override 'options' objects going through syncAPIClient
This commit is contained in:
parent
dcb7c88ebd
commit
aab4fca3ad
1 changed files with 16 additions and 9 deletions
|
@ -46,7 +46,10 @@ Zotero.Sync.APIClient.prototype = {
|
||||||
|
|
||||||
getKeyInfo: Zotero.Promise.coroutine(function* (options={}) {
|
getKeyInfo: Zotero.Promise.coroutine(function* (options={}) {
|
||||||
var uri = this.baseURL + "keys/" + this.apiKey;
|
var uri = this.baseURL + "keys/" + this.apiKey;
|
||||||
var xmlhttp = yield this.makeRequest("GET", uri, Object.assign(options, { successCodes: [200, 404] }));
|
let opts = {};
|
||||||
|
Object.assign(opts, options);
|
||||||
|
opts.successCodes = [200, 404];
|
||||||
|
var xmlhttp = yield this.makeRequest("GET", uri, opts);
|
||||||
if (xmlhttp.status == 404) {
|
if (xmlhttp.status == 404) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -548,11 +551,13 @@ Zotero.Sync.APIClient.prototype = {
|
||||||
|
|
||||||
|
|
||||||
getHeaders: function (headers = {}) {
|
getHeaders: function (headers = {}) {
|
||||||
headers["Zotero-API-Version"] = this.apiVersion;
|
let newHeaders = {};
|
||||||
|
newHeaders = Object.assign(newHeaders, headers);
|
||||||
|
newHeaders["Zotero-API-Version"] = this.apiVersion;
|
||||||
if (this.apiKey) {
|
if (this.apiKey) {
|
||||||
headers["Zotero-API-Key"] = this.apiKey;
|
newHeaders["Zotero-API-Key"] = this.apiKey;
|
||||||
}
|
}
|
||||||
return headers;
|
return newHeaders;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -560,16 +565,18 @@ Zotero.Sync.APIClient.prototype = {
|
||||||
if (!this.apiKey && !options.noAPIKey) {
|
if (!this.apiKey && !options.noAPIKey) {
|
||||||
throw new Error('API key not set');
|
throw new Error('API key not set');
|
||||||
}
|
}
|
||||||
options.headers = this.getHeaders(options.headers);
|
let opts = {}
|
||||||
options.dontCache = true;
|
Object.assign(opts, options);
|
||||||
options.foreground = !options.background;
|
opts.headers = this.getHeaders(options.headers);
|
||||||
options.responseType = options.responseType || 'text';
|
opts.dontCache = true;
|
||||||
|
opts.foreground = !options.background;
|
||||||
|
opts.responseType = options.responseType || 'text';
|
||||||
var tries = 0;
|
var tries = 0;
|
||||||
var failureDelayGenerator = null;
|
var failureDelayGenerator = null;
|
||||||
while (true) {
|
while (true) {
|
||||||
var result = yield this.caller.start(Zotero.Promise.coroutine(function* () {
|
var result = yield this.caller.start(Zotero.Promise.coroutine(function* () {
|
||||||
try {
|
try {
|
||||||
var xmlhttp = yield Zotero.HTTP.request(method, uri, options);
|
var xmlhttp = yield Zotero.HTTP.request(method, uri, opts);
|
||||||
this._checkBackoff(xmlhttp);
|
this._checkBackoff(xmlhttp);
|
||||||
return xmlhttp;
|
return xmlhttp;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue