diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index a98cfd9ece..268c3e7a54 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -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 * diff --git a/chrome/content/zotero/xpcom/utilities_translate.js b/chrome/content/zotero/xpcom/utilities_translate.js index 89ea3e57dd..630e644068 100644 --- a/chrome/content/zotero/xpcom/utilities_translate.js +++ b/chrome/content/zotero/xpcom/utilities_translate.js @@ -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) {