From 2b8c28ccaf7af8485981cf6df85140fac2cfcd5f Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 3 Apr 2013 14:37:02 -0400 Subject: [PATCH] Support file:/// URIs in Zotero.HTTP.promise() --- chrome/content/zotero/xpcom/http.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js index d21292d0a..d1721fb6f 100644 --- a/chrome/content/zotero/xpcom/http.js +++ b/chrome/content/zotero/xpcom/http.js @@ -121,18 +121,20 @@ Zotero.HTTP = new function() { } // Send cookie even if "Allow third-party cookies" is disabled (>=Fx3.6 only) - var channel = xmlhttp.channel; - channel.QueryInterface(Components.interfaces.nsIHttpChannelInternal); - channel.forceAllowThirdPartyCookie = true; - - // Set charset - if (options && options.responseCharset) { - channel.contentCharset = responseCharset; - } - - // Disable caching if requested - if(options && options.dontCache) { - channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE; + var channel = xmlhttp.channel, + isFile = channel instanceof Components.interfaces.nsIFileChannel; + if(channel instanceof Components.interfaces.nsIHttpChannelInternal) { + channel.forceAllowThirdPartyCookie = true; + + // Set charset + if (options && options.responseCharset) { + channel.contentCharset = responseCharset; + } + + // Disable caching if requested + if(options && options.dontCache) { + channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE; + } } // Set responseType @@ -155,6 +157,9 @@ Zotero.HTTP = new function() { if (options && options.successCodes) { var success = options.successCodes.indexOf(status) != -1; } + else if(isFile) { + var success = status == 200 || status == 0; + } else { var success = status >= 200 && status < 300; }