Http response header not getting modified in firefox extension always
I am modifying the inlinedisposition extension of firefox. Here is the code snippet which actually modifies the 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
}
}
The line which I added to modify the content-type is not working. Content-disposition works fine however.
Content-Type
is one of the response headers that cannot be modified. The others are Content-Lenght
, Content-Encoding
, Trailer
and Transfer-Encoding
.
However you can change the inherited contentType
attribute of nsIHttpChannel (some restrictions apply).
上一篇: 不要转载选项+提示