From 6d7dcc44bcc6cbe0f555a264c569745294596222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Tue, 18 Jul 2017 10:25:54 +0300 Subject: [PATCH] Add connector endpoint to retrieve proxies. Closes #1265 --- .../content/zotero/xpcom/server_connector.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/chrome/content/zotero/xpcom/server_connector.js b/chrome/content/zotero/xpcom/server_connector.js index f7bda2439..1301fe69d 100644 --- a/chrome/content/zotero/xpcom/server_connector.js +++ b/chrome/content/zotero/xpcom/server_connector.js @@ -776,6 +776,31 @@ Zotero.Server.Connector.GetClientHostnames.prototype = { }) }; +/** + * Get a list of stored proxies + * + * Accepts: + * Nothing + * Returns: + * {Array} hostnames + */ +Zotero.Server.Connector.Proxies = {}; +Zotero.Server.Connector.Proxies = function() {}; +Zotero.Server.Endpoints["/connector/proxies"] = Zotero.Server.Connector.Proxies; +Zotero.Server.Connector.Proxies.prototype = { + supportedMethods: ["POST"], + supportedDataTypes: ["application/json"], + permitBookmarklet: false, + + /** + * Returns a 200 response to say the server is alive + */ + init: Zotero.Promise.coroutine(function* () { + let proxies = Zotero.Proxies.proxies.map((p) => Object.assign(p.toJSON(), {hosts: p.hosts})); + return [200, "application/json", JSON.stringify(proxies)]; + }) +}; + /** * Test connection