I am developing a Firefox extension for FF2.0.0.x, and I use the
following method to capture a request. In this way I can capture all
kinds of HttpRequest sent by Firefox, including normal HttpRequest and
XMLHttpRequest. But I only care about normal HttpRequest. So could
anybody tell me how can I distinguish XMLHttpRequest from normal
HttpRequest.
function HttpInfoLive(){}
HttpInfoLive.prototype =
{
observe: function(aSubject, aTopic, aData)
{
// when requesting and responsing, the observe is invoked;
if (aTopic == 'http-on-modify-request')
{
aSubject.QueryInterface(Components.interfaces.nsIHttpChannel);
this.onVisitRequest(aSubject);
}
},
onVisitRequest : function(oHttp)
{
this.onVisitRequestHeader(oHttp);
this.getPostData(oHttp);
},
onVisitRequestHeader : function(oHttp)
{
var str = "";
str += "url=" + oHttp.URI.asciiSpec;
var headerArray = new Array();
var visitor = new HttpHeaderVisitor(headerArray);
oHttp.visitRequestHeaders(visitor);
for(var i in headerArray)
{
str += "&" + i + "=" + headerArray[i];
}
alert("request:" + str);
}
}
_______________________________________________
dev-tech-network mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-network