简体   繁体   中英

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 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM