gpt4 book ai didi

javascript - HTTP 响应 header 在 Firefox 扩展中始终未被修改

转载 作者:行者123 更新时间:2023-11-30 17:52:33 29 4
gpt4 key购买 nike

我正在修改 firefox 的 inlinedisposition 扩展。这是实际修改 header 的代码片段:

_httpResponse: function( chan )
{
var disp = "";


try {
chan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
disp = chan.getResponseHeader("Content-Disposition");
} catch (e) { }

if (chan.loadFlags & Components.interfaces.nsIChannel.LOAD_DOCUMENT_URI && this._re.test(disp))
{
chan.setResponseHeader("Content-Disposition", disp.replace(this._re, "inline"), false);
chan.setResponseHeader("Content-Type", "application/fgdownload", false); //not working
}

}

我添加的用于修改内容类型的行不起作用。然而,内容处置工作正常。

最佳答案

Content-Type 是无法修改的响应 header 之一。其他的是 Content-LenghtContent-EncodingTrailerTransfer-Encoding

但是,您可以更改 nsIHttpChannel ( some restrictions apply) 的继承 contentType 属性。

关于javascript - HTTP 响应 header 在 Firefox 扩展中始终未被修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18687429/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com