Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8439245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:57:28+00:00 2026-06-10T07:57:28+00:00

I am developing a Firefox extension on the Addon SDK (V1.9). Objective I need

  • 0

I am developing a Firefox extension on the Addon SDK (V1.9).

Objective

I need to examine HTTP requests for a specific content type before they are loaded (before the request is sent).

Problem

When adding an observer through the ‘observer-service’ module, I use “http-on-modify-request” to examine all HTTP requests. This provides the headers. However, when checking for content-type, it is never set on request.

Content-type is indeed set on response, which I examine using “http-on-examine-response”. But this means that the request has already loaded, defeating the purpose of my extension.

Edit

@Wladimir Palant Thanks for pointing out that content-type is not set when the request headers are being sent.

I am trying to test HTTP requests’ urls on a bunch of regexes that are relevant for me and block them. However, I wanted to be able to skip certain content-types (such as images) since they are not relevant for my application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:57:29+00:00Added an answer on June 10, 2026 at 7:57 am

    So, to wrap up on the issue. The best way to have full control of resources loading into the browser seems to be using nsIContentPolicy.

    @WladimirPalant wrote a great example here. And this is how his code would look adapted to the Addon SDK (v1.9):

    const { Cc, Ci, Cu, Cm, components } = require('chrome');
    const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm");
    
    
    let policy =
    {
        classDescription: "Test content policy",
        classID: components.ID("{12345678-1234-1234-1234-123456789abc}"),
        contractID: "@adblockplus.org/test-policy;1",
        xpcom_categories: ["content-policy"],
    
        init: function()
        {
            let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
            registrar.registerFactory(this.classID, this.classDescription, this.contractID, this);
    
            let catMan = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
            for each (let category in this.xpcom_categories)
                catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true);
    },
    
        // nsIContentPolicy interface implementation
        shouldLoad: function(contentType, contentLocation, requestOrigin, node, mimeTypeGuess, extra)
        {
            dump("shouldLoad: " + contentType + " " +
                          (contentLocation ? contentLocation.spec : "null") + " " +
                          (requestOrigin ? requestOrigin.spec : "null") + " " +
                          node + " " +
                          mimeTypeGuess + "\n");
            return Ci.nsIContentPolicy.ACCEPT;
        },
    
        shouldProcess: function(contentType, contentLocation, requestOrigin, node, mimeTypeGuess, extra)
        {
            dump("shouldProcess: " + contentType + " " +
                            (contentLocation ? contentLocation.spec : "null") + " " +
                            (requestOrigin ? requestOrigin.spec : "null") + " " +
                            node + " " +
                            mimeTypeGuess + "\n");
            return Ci.nsIContentPolicy.ACCEPT;
        },
    
        // nsIFactory interface implementation
        createInstance: function(outer, iid)
        {
            if (outer)
                throw Cr.NS_ERROR_NO_AGGREGATION;
            return this.QueryInterface(iid);
        },
    
        // nsISupports interface implementation
        QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy, Ci.nsIFactory])
    };
    
    policy.init();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a Firefox extension and need to access a specific cookie from
I am developing an extension on Firefox's Addon SDK (v1.9). My extension blocks or
I am developing a Firefox extension and I need to perform some high-speed calculations
I am developing a firefox extension, i need to detect which operating system firefox
I am currently developing a Firefox extension, and I need the ability to be
I'm developing a site-specific Firefox extension. The official hosting/updating mechanism at addons.mozilla.org forces my
I'm developing a Firefox extension. There is a menu X which I need to
I am developing a Firefox extension which need to change some values on a
I am developing a firefox extension and I need to include the Google Search
I am developing my first Firefox extension and for that I need to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.