diff --git a/chrome/content/zotero/xpcom/connector/connector.js b/chrome/content/zotero/xpcom/connector/connector.js index 7a98b2cd5..79af62367 100644 --- a/chrome/content/zotero/xpcom/connector/connector.js +++ b/chrome/content/zotero/xpcom/connector/connector.js @@ -25,7 +25,7 @@ Zotero.Connector = new function() { const CONNECTOR_URI = "http://127.0.0.1:23119/"; - const CONNECTOR_SERVER_API_VERSION = 1; + const CONNECTOR_API_VERSION = 2; this.isOnline = null; @@ -69,8 +69,18 @@ Zotero.Connector = new function() { } if(Zotero.Connector.EXCEPTION_CODES.indexOf(req.status) !== -1) { - Zotero.debug("Connector: Method "+method+" failed"); + Zotero.debug("Connector: Method "+method+" failed with status "+req.status); if(callback) callback(false, req.status); + + // Check for incompatible version + if(req.status === 404 || req.status === 412) { + if(Zotero.Connector_Browser && Zotero.Connector_Browser.onIncompatibleStandaloneVersion) { + var standaloneVersion = req.getResponseHeader("X-Zotero-Version"); + Zotero.Connector_Browser.onIncompatibleStandaloneVersion(Zotero.version, standaloneVersion); + throw "Connector: Version mismatch: Connector version "+Zotero.version + +", Standalone version "+(standaloneVersion ? standaloneVersion : ""); + } + } } else { Zotero.debug("Connector: Method "+method+" succeeded"); var val = null; @@ -91,6 +101,10 @@ Zotero.Connector = new function() { var uri = CONNECTOR_URI+"connector/"+method; Zotero.HTTP.doPost(uri, JSON.stringify(data), - newCallback, {"Content-Type":"application/json"}); + newCallback, { + "Content-Type":"application/json", + "X-Zotero-Version":Zotero.version, + "X-Zotero-Connector-API-Version":CONNECTOR_API_VERSION + }); } } \ No newline at end of file diff --git a/chrome/content/zotero/xpcom/server.js b/chrome/content/zotero/xpcom/server.js index 2e7a14a4e..c6a4ffcc8 100755 --- a/chrome/content/zotero/xpcom/server.js +++ b/chrome/content/zotero/xpcom/server.js @@ -67,6 +67,10 @@ Zotero.Server = new function() { */ this.generateResponse = function (status, contentType, body) { var response = "HTTP/1.0 "+status+" "+responseCodes[status]+"\r\n"; + if(!Zotero.isServer) { + response += "X-Zotero-Version: "+Zotero.version+"\r\n"; + response += "X-Zotero-Connector-API-Version: "+CONNECTOR_API_VERSION+"\r\n"; + } if(body) { if(contentType) { diff --git a/chrome/content/zotero/xpcom/server_connector.js b/chrome/content/zotero/xpcom/server_connector.js index fd90687c1..ddcc44629 100755 --- a/chrome/content/zotero/xpcom/server_connector.js +++ b/chrome/content/zotero/xpcom/server_connector.js @@ -1,7 +1,7 @@ /* ***** BEGIN LICENSE BLOCK ***** - Copyright © 2009 Center for History and New Media + Copyright © 2011 Center for History and New Media George Mason University, Fairfax, Virginia, USA http://zotero.org @@ -22,8 +22,7 @@ ***** END LICENSE BLOCK ***** */ - -const CONNECTOR_SERVER_API_VERSION = 2; +const CONNECTOR_API_VERSION = 2; Zotero.Server.Connector = function() {}; Zotero.Server.Connector._waitingForSelection = {}; @@ -406,4 +405,9 @@ Zotero.Server.Connector.Ping.prototype = { "init":function(postData, sendResponseCallback) { sendResponseCallback(200); } -} \ No newline at end of file +} + + +// XXX For compatibility with older connectors; to be removed +Zotero.Server.Endpoints["/translate/list"] = Zotero.Server.Connector.GetTranslators; +Zotero.Server.Endpoints["/translate/save"] = Zotero.Server.Connector.SavePage; \ No newline at end of file