I am new to add-in development and now I am afraid of this problem. There are some questions that are somehow related, but they have not yet helped me find a solution.
So, I am developing a Firefox add-on that reads one specific header when any web page is loaded onto any tab in the browser.
I can load observer tabs, but I don't think there is a way to read the http headers inside the following (simple) code, only the URL. Please correct me if I am wrong.
var tabs = require("sdk/tabs"); tabs.on('open', function(tab){ tab.on('ready', function(tab){ console.log(tab.url); }); }); });
I can also read response headers by observing http events as follows:
var {Cc, Ci} = require("chrome"); var httpRequestObserver = { init: function() { var observerService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); observerService.addObserver(this, "http-on-examine-response", false); }, observe: function(subject, topic, data) { if (topic == "http-on-examine-response") { subject.QueryInterface(Ci.nsIHttpChannel); this.onExamineResponse(subject); } }, onExamineResponse: function (oHttp) { try { var header_value = oHttp.getResponseHeader("<the_header_that_i_need>");
The problem (and the main source of personal confusion) is that when I read the response headers, I don't know what the request is for. I want to somehow display the request (especially the address of the request) and the response header ("the_header_that_i_need").
source share