Search code examples
firefox-addon-sdk

how can I get all header values for a request in firefox addon sdk?


I am trying to read headers using the firefox addon sdk using nsIHttpChannel

like..

var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
console.log(httpChannel.getRequestHeader("Host"));

works but I would like to replicate the complete header and the getRequestHeader only allows asking for one specific line. Do you know of a way to loop true all of them?

I tried serialisazion but that only leads to ({}).

for (var key in httpChannel) {
   if (httpChannel.hasOwnProperty(key)) {
      console.log(key + " -> " + httpChannel[key]); 
   }

list only Attributes but not the headers


Solution

  • httpChannel.visitRequestHeaders(function(header, value){
      // do something
    });