Add setRequestHeaders() method to Translate.Web
For use in zotero/translation-server#16 to pass Accept-Language through to translation web requests
This commit is contained in:
parent
a6fb0b35c3
commit
0706430609
2 changed files with 9 additions and 2 deletions
|
@ -2053,6 +2053,13 @@ Zotero.Translate.Web.prototype.setCookieSandbox = function(cookieSandbox) {
|
|||
this.cookieSandbox = cookieSandbox;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets headers to include in HTTP requests. Used by translation-server.
|
||||
*/
|
||||
Zotero.Translate.Web.prototype.setRequestHeaders = function (headers) {
|
||||
this.requestHeaders = headers;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the location to operate upon
|
||||
*
|
||||
|
|
|
@ -360,7 +360,7 @@ Zotero.Utilities.Translate.prototype.doGet = function(urls, processor, done, res
|
|||
} catch(e) {
|
||||
translate.complete(false, e);
|
||||
}
|
||||
}, responseCharset, this._translate.cookieSandbox, requestHeaders);
|
||||
}, responseCharset, this._translate.cookieSandbox, Object.assign({}, this._translate.requestHeaders, requestHeaders));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -393,7 +393,7 @@ Zotero.Utilities.Translate.prototype.doPost = function(url, body, onDone, header
|
|||
} catch(e) {
|
||||
translate.complete(false, e);
|
||||
}
|
||||
}, headers, responseCharset, translate.cookieSandbox ? translate.cookieSandbox : undefined);
|
||||
}, Object.assign({}, translate.requestHeaders, headers), responseCharset, translate.cookieSandbox ? translate.cookieSandbox : undefined);
|
||||
}
|
||||
|
||||
Zotero.Utilities.Translate.prototype.urlToProxy = function(url) {
|
||||
|
|
Loading…
Reference in a new issue