Tony Tony - 4 months ago 12x
Javascript Question

Read http Headers for extension

I want to get the complete information of a http header when a http request has made by using http-on-modify-request.

Example of the information i want to get:

enter image description here

i have this code:

myObserver.prototype = {
observe: function(subject, topic, data) {

var httpChannel =
alert("URI: " + httpChannel.originalURI.spec);
alert("User-Agent: " + httpChannel.getRequestHeader('user-agent'));

register: function() {
var observerService = Components.classes[";1"]
observerService.addObserver(this, "http-on-modify-request", false);
unregister: function() {
var observerService = Components.classes[";1"]
observerService.removeObserver(this, "http-on-modify-request");


I never used a way of getting them all at once, but you should be able to get them individually with the way you are doing.

I tried it too for the referer, but it didn't work, but i found that if you do: 

(referrer has two r's), it shows the address of the referer.

Additionally, you might want to take a look at the source code of httpfox, it does what you are trying to do.

You might find additional help in this link: nsITraceableChannel, Intercept HTTP Traffic | Software is hard

And this one: Howto: XHR Listening by a Firefox Addon