当使用 http-on-modify-request 发出 http 请求时,我想获取 http 标头的完整信息。
我想获得的信息示例:
我有这个代码:
myObserver.prototype = {
observe: function(subject, topic, data) {
if("http-on-modify-request"){
var httpChannel =
subject.QueryInterface(Components.interfaces.nsIHttpChannel);
alert("URI: " + httpChannel.originalURI.spec);
alert("User-Agent: " + httpChannel.getRequestHeader('user-agent'));
}
},
register: function() {
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.addObserver(this, "http-on-modify-request", false);
},
unregister: function() {
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.removeObserver(this, "http-on-modify-request");
}
}