Controlling HTTP Requests through XPCom


Below is the code through which you can moniter, modify, suspend any http request in your firefox plugin. I have taken help from Mozilla Forums . You can get more information about nsIHttpChannel from here and here.

var observerService =Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.addObserver(observer,"http-on-modify-request",false);
var observer = {
    observe: function(aSubject,topic,data){
            var oHttp = aSubject.QueryInterface(Components.interfaces.nsIHttpChannel);
            if (oHttp.name.toString().indexOf("anydomain.com")!=-1 )
                // perform your required functionality here. The request is suspended until the this code is executed.
    }
};
Advertisements

I am a web developer working @ Gaditek

Posted in Browser Extension Development, Programming & Development
One comment on “Controlling HTTP Requests through XPCom
  1. […] . You can get more information about nsIHttpChannel from here and here. var observerService… [full post] dreamxtream DreamXtream's Blog browser extension developmentprogramming & development […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

About me
A geek trying to make world a better place to live.

I mostly work on Web Technologies like PHP, Javascript. I also work on Python, GAE and Netsuite Customization. Currently working @ Cloudways

Profile Links Linkedin | Github | Stackoverflow
Subscribe to this blog
%d bloggers like this: