diff --git a/lib/main.js b/lib/main.js index e0cbea8bd..ef3a5fed2 100644 --- a/lib/main.js +++ b/lib/main.js @@ -7,7 +7,6 @@ const parent = require('sdk/remote/parent') exports.main = function (options, callbacks) { // eslint-disable-line no-unused-vars require('./redirects.js') - require('./request-fix.js') require('./peer-watch.js') protocols.register() parent.remoteRequire('./child-main.js', module) diff --git a/lib/protocols.js b/lib/protocols.js index cc273864a..2fc9d86b1 100644 --- a/lib/protocols.js +++ b/lib/protocols.js @@ -121,14 +121,18 @@ CommonProtocolHandler.prototype = Object.freeze({ if (gw.fsUris && this.scheme === FS_SCHEME) { channel.originalURI = aURI channel.loadFlags &= ~Ci.nsIChannel.LOAD_REPLACE - // channel.loadFlags |= Ci.nsIChannel.LOAD_ANONYMOUS - } - channel.loadInfo = loadInfo + // Cookies make no sense in the ipfs context + // unless we have Suborigin header support. + // Until https://git.io/vgAMj is resolved + // we don't want to carry different gateway cookies into the page + channel.loadFlags |= Ci.nsIRequest.LOAD_ANONYMOUS - channel.QueryInterface(Ci.nsIWritablePropertyBag) - channel.QueryInterface(Ci.nsIWritablePropertyBag2) - channel.setPropertyAsAString('ipfs-uri', aURI.spec) + if (isIPFS.ipfsPath(aURI.path)) { + // no revalidation for /ipfs/ from cache, those are immutable + channel.loadFlags |= Ci.nsIRequest.VALIDATE_NEVER + } + } // console.info('newChannel routed to HTTP gateway: ' + channel.URI.spec) return channel diff --git a/lib/request-fix.js b/lib/request-fix.js deleted file mode 100644 index 5a4eed19c..000000000 --- a/lib/request-fix.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict' - -const {Ci} = require('chrome') -const events = require('sdk/system/events') -const gw = require('./gateways.js') - -/* -const catman = Cc['@mozilla.org/categorymanager;1'].getService(CI.nsICategoryManager) -// category ("net-channel-event-sinks") -catman.addCategoryEntry(in string aCategory, in string aEntry, in string aValue, in boolean aPersist, in boolean aReplace) -*/ - -function fixupRequest (e) { - if (e.type !== 'http-on-modify-request') { - return - } - if (!gw.fsUris) { - return - } - const channel = e.subject.QueryInterface(Ci.nsIHttpChannel) - - channel.QueryInterface(Ci.nsIHttpChannelInternal) - channel.QueryInterface(Ci.nsIPropertyBag2) - channel.QueryInterface(Ci.nsIPropertyBag) - - let isIpfsReq = null - try { - isIpfsReq = channel.hasKey('ipfs-uri') - } catch (e) { - // console.log(e) - } - - if (isIpfsReq && channel.originalURI.scheme === 'fs') { - /* - // TODO: investigate effects of the following flags - // cookies make no sense in the ipfs context, we don't want to carry different gateway cookies into the page - channel.loadFlags |= Ci.nsIRequest.LOAD_ANONYMOUS - // should only do that for /ipfs/ paths since those are stable - channel.loadFlags |= Ci.nsIRequest.VALIDATE_NEVER - */ - - // prevent redirects from replacing the effective URI - channel.loadFlags &= ~Ci.nsIChannel.LOAD_REPLACE - } -} - -events.on('http-on-modify-request', fixupRequest)