Released: Modify Headers 0.6.3

Happy New Year to you all.

Before Christmas I released version 0.6.3 of Modify Headers. This version adds support for the Firefox 3 beta 2. For current users this will automatically update, otherwise, please download from Mozilla Addons.

Update: XHTML Mobile Profile 0.5.2 has been updated to support Firefox 3 beta 2.

This entry was posted in Firefox. Bookmark the permalink.

10 Responses to Released: Modify Headers 0.6.3

  1. NettiCat says:

    First reading about the “Modify Headers” extension I thought: That’s what I ‘m looking for.
    But after installing the extension, it revealed to modify outging (request-) headers only. No possibility to modify or remove server-sided response headers. Yes, I should have read your extension-description more carefully, you mentioned it.
    Ok, you may ask, why should I want to filter response headers? Answer: There are several reasons why you may want to filter server headers. One of them is to force caching in firefox.
    Many servers send anti-cache headers, preventing firefox to cache documents and/or pictures, so there will always be a (full) reload when pushing the back button. That’s really annoying. Anti-cache headers may be AGE, CACHE-CONTROL, EXPIRES, ETAG, PRAGMA, VARY and even more headers.
    I really would appreciate adding that feature.

  2. gareth says:

    Hi NettiCat. I had always thought that response headers are immutable, but I had a look at the documentation and it looks possible. I’ve added an enhancement request here: https://www.mozdev.org/bugs/show_bug.cgi?id=18455

    Feel free to add yourself as a CC on this.

    I have a lot of other features to add first, but I’ll add this to the roadmap for version 0.8 or 0.9.

  3. NettiCat says:

    Thank you! (for adding my request to the road map)

  4. NettiCat says:

    P.S.

    ACString getResponseHeader(in ACString header);

    void setResponseHeader(in ACString header, in ACString value, in boolean merge);

    http://developer.mozilla.org/en/docs/nsIHttpChannel

  5. NettiCat says:

    This may not be of interest for bloggers, but as all postings will be reviewed I’ll post it anyway :-)
    I made a small extension (BetterCache). It is a working demo concerning modification of response headers. You may use it in your own project:

    function RespHeaderObserver()
    {
    this.register();
    }

    RespHeaderObserver.prototype = {
    observe: function(subject, topic, data) {
    if (topic == “http-on-examine-response”) {
    var headers = new Array();
    headers[0] = “Age”;
    headers[1] = “Cache-Control”;
    headers[2] = “Date”;
    headers[3] = “ETag”;
    headers[4] = “Expires”;
    headers[5] = “Last-Modified”;
    headers[6] = “Pragma”;
    headers[7] = “Vary”;
    //headers[8] = “Set-Cookie”; //not anti-cache, but a better testpattern :-)
    var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
    //need to test every (above defined) header for existance. If not existant, getResponseHeader will throw an exception.
    for(i = 0; i < headers.length; i++){
    var headerval = “”;
    var replacement = “”;
    try{
    headerval = httpChannel.getResponseHeader (headers[i]);
    if(i == 6)//special case Pragma
    replacement = headerval.replace(/no\-cache/g, “”);
    httpChannel.setResponseHeader(headers[i], replacement, false);
    //alert(headers[i]+’='+headerval);
    }catch(e){}//NS_ERROR_(header_)NOT_AVAILABLE
    }
    headers = null;
    return;
    }
    },

    register: function() {
    var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
    observerService.addObserver(this, “http-on-examine-response”, false);
    },
    unregister: function() {
    var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
    try{
    observerService.removeObserver(this, “http-on-examine-response”);
    }catch(e){}
    }
    }
    //observer needs to be registered only once, so better use a XPT file
    window.addEventListener(“load”, function(evnt) { observer = new RespHeaderObserver(); }, true);
    window.addEventListener(“unload”, function(evnt) { observer.unregister(); }, true);

  6. crono says:

    Hi,
    I found your extension today and think it’s really great. It would be perfect for me when I could specify which headers are sent to which url (with regex).

    Example:
    x-test0 = 0000 @ http://a-z\./]*
    x-test = 1234 @ https://localhost/*
    x-test2 = 5678 @ http://www\.mozilla\.org/*

    and so on… Just an idea :-)

  7. gareth says:

    Hi Crono, A feature similar to this is already on the roadmap.

  8. crono says:

    Hi Gareth,

    very nice – thanks for the info :-)

    bye

  9. Tim says:

    I think the best reason to be able to modify server side headers is… freedom.

  10. MazarD says:

    Congratulations for this awesome extension!, but I also miss the modify response headers feature. Another usage could be to filter the location header for testing purposes, the developers would appreciate it very much.

    Best regards.
    MazarD