XPCOM:嗅探 HTTP 响应
我想用 XPCOM 编写一个小组件,可以嗅探浏览器收到的所有 HTTP 响应。现在,我能找到的唯一示例(如下面附加的示例)仅允许我检索我自己触发的请求的响应:
var req = new XMLHttpRequest();
req.open('GET', 'http://www.mozilla.org/', true);
req.onreadystatechange = function (aEvt) {
if (req.readyState == 4) {
if(req.status == 200)
dump(req.responseText);
else
dump("Error loading page\n");
}
};
我想要的是浏览器收到的任何 HTTP 响应都获取相应的 HTTP 标头要求。
谢谢
I would like to write a little component with XPCOM that can sniff all HTTP responses received by the browser. Right now the only examples that I can find (like the one appended below) only allow me to retrieve the response for a request that I fire myself:
var req = new XMLHttpRequest();
req.open('GET', 'http://www.mozilla.org/', true);
req.onreadystatechange = function (aEvt) {
if (req.readyState == 4) {
if(req.status == 200)
dump(req.responseText);
else
dump("Error loading page\n");
}
};
What I want is for any HTTP response that the browser receives get the HTTP headers of the corresponding request.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以使用
http-on-modify-request
和http-on-examine-response
通知。请参阅https://developer.mozilla.org/en/XUL_School/Intercepting_Page_Loads#HTTP_ObserversYou can also use the
http-on-modify-request
andhttp-on-examine-response
notifications. See https://developer.mozilla.org/en/XUL_School/Intercepting_Page_Loads#HTTP_Observers您可以通过 nsIHttpActivityObserver 嗅探所有 http 流量,这是从 Firefox Web 控制台抄写的示例:
和
You can sniff all http traffic via the nsIHttpActivityObserver, an example cribbed from the Firefox web console:
and http://mxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/nsIHttpActivityObserver.idl