[Project_owners] http-on-examine-response, page titles

Stan James sjames at uni-osnabrueck.de
Wed Sep 14 11:08:16 EDT 2005


Hi all,

I'm using an observer to get notified of all HTTP events, but am having 
trouble getting the page titles of successfully loaded pages. I need to 
track the redirects leading up to the final page, and then be able to 
identify the whole sequence by the title of the resulting page.

I can set up an oberserver like this:
        var observerService =
            
Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
        observerService.addObserver(gMyObserver, 
"http-on-examine-response", false);

With an oberver like this:
    var gMyObserver =
    {
        observe : function(aHttpChannel, aTopic, aData)
        {

            
aHttpChannel.QueryInterface(Components.interfaces.nsIHttpChannel);

            // we only care about document loading events
            if (!(aHttpChannel.loadFlags & 
aHttpChannel.LOAD_DOCUMENT_URI)) return;

            var uri =    aHttpChannel.URI.spec;
            var responseStatus =     aHttpChannel.responseStatus;
            var requestMethod = aHttpChannel.requestMethod;

            // do more stuff...
        }
    };

But then there seems no way to access any info about the loaded page 
from the channel object. I can use a normal onload events to grab the 
page title, but then it's a real bitch to associate it with the correct 
http events...plus the fact that the observer works cross-window while 
onload events are window-specific.

Any ideas? Thanks for any help!

-stan



More information about the Project_owners mailing list