Thank you very much Michel,
your answer really helped me.
Do you know where can i find a list of existing notifications
(i.e. "http-on-modify-request","http-on-examine-response"), available to
register an observer with ?
In other words how or where can i find out what is available to hook
(register an observer) to ?
Thanks again
Andrea


Michel Gutierrez wrote:
>> I would like to add some http headers (by creating and installing a
>> firefox extension), to all the http requests that firefox makes.
>> Could anyone point me to the right direction ?
> 
> 
> You can register an observer that will be called just before the http
> request is actually issued. For instance, the code below will change the
> referer field on outgoing requests.
> 
>   var observerService =
>     Components.classes["@mozilla.org/observer-service;1"]
>       .getService(Components.interfaces.nsIObserverService);
> 
>   var reqObserver = {
>     observe: function(subject,topic,data) {
>       var request =
> subject.QueryInterface(Components.interfaces.nsIRequest);
>       dump("Request: "+request.name+"\n");
>       var httpChannel =
> subject.QueryInterface(Components.interfaces.nsIHttpChannel);
>       httpChannel.setRequestHeader("referer",
> "http://myreferer.com/",false);
>     }
>   };   
>   observerService.addObserver(reqObserver, "http-on-modify-request",false);
> 
> You can also hook the http response using "http-on-examine-response"
> instead of "http-on-modify-request".
> 
> /mig
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to