Hi,
Is there a way to block HTTP GET requests initiated by HTTP redirect
responses?
I'm trying to use nsIContentPolicy and listen to http-on-modify-
request topic but neither way allows to catch the GET request
initiated by HTTP 301.
I.e. GET to tinyurl.com results in HTTP 301 with 'Location' header set
to some URL but neither nsIContentPolicy nor http-on-modify-request
can't find the URL.
I use the following code:
var MyListener = {
// listen to http-on-modify-request topic
observe: function(subject, topic, data) {
if (topic == "app-startup") {
var os = Components.classes["@mozilla.org/observer-service;
1"]
.getService(nsIObserverService);
os.addObserver(this, "http-on-modify-request", false);
} else if (topic == "http-on-modify-request") {
var channel = subject.QueryInterface(nsIHttpChannel);
var match = this.pattern.exec(channel.originalURI.spec);
if (match) { ... }
}
},
// nsIContentPolicy implementation
shouldLoad: function(type, location, origin, ctx, mime, extra) {
if (type == nsIContentPolicy.TYPE_DOCUMENT) {
var match = this.pattern.exec(location.spec);
if ( match ) { ... }
}
},
....
}
It works well for most cases except GET requests initiated by HTTP 301
responses.
Thanks,
Denis
_______________________________________________
dev-tech-network mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-network