由于我正在寻找解决方案,而没有可用的附加组件实际上可以与我的Firefox 31.0(Ubuntu)配合使用,因此我决定尝试创建自己的附加组件。
如果您想要实现类似的目标或只是想了解它的工作原理,请查看以下代码。
console.log("starting addon to disable content-disposition...");
var {Cc, Ci} = require("chrome");
var httpResponseObserver = {
observe: function(subject, topic, data) {
if (topic == "http-on-examine-response") {
var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
httpChannel.setResponseHeader("Content-Disposition", "inline", false);
}
},
get observerService() {
return Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
},
register: function() {
console.log("register with an observer to get response-events");
this.observerService.addObserver(this, "http-on-examine-response", false);
},
unregister: function() {
console.log("unregister from observer");
this.observerService.removeObserver(this, "http-on-examine-response");
}
};
exports.main = function(options, callbacks) {
console.log("content-dispostion main method got invoked");
httpResponseObserver.register();
};
exports.onUnload = function(reason) {
console.log("content-dispostion unloaded");
httpResponseObserver.unregister();
};
作为替代方案,您可以获取我的XPI文件直接在Firefox中安装此插件。如果您想禁用“Content-Disposition”修改,则只需停用该添加程序;-)。
http://www.file-upload.net/download-9374691/content-disposition_remover.xpi.html