2012-11-20 30 views
2

我想讀通過使用nsIHttpChannel如何在firefox addon sdk中獲取所有請求的標題值?

像火狐插件SDK頭..

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

的作品,但我想複製完整的頭和getRequestHeader只允許要求一個特定的線路。你知道一種方法來循環所有這些嗎?

我試過serialisazion但只能導致({})。

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

只列出屬性,但不是頭

回答

3
httpChannel.visitRequestHeaders(function(header, value){ 
    // do something 
}); 
+0

謝謝,僅此而已。 – Franz657587

相關問題