Bypass LiveHTTPHeaders Error: Components is not defined

November 26, 2005 at 11:00 pm (HowTo)

I just installed LiveHTTPHeaders extension into my firefox yesterday. Actually I have been using it since my Mozilla-suite’s old days, and it really helped a lot during the endless debugging sessions in my thesis project (Well, finally I’m a graduate now! :) ).

I have noticed this bug since then. When you run the LiveHTTPHeaders window, everything are just cool until after you close it, the Javascript Console will be flooded by a repeating error:

Error: Components is not defined Source File: chrome://livehttpheaders/content/LiveHTTPHeaders.js Line: 427

Thanks to Daniel Kabs’s workaround, now the bug is bypassed (as he said, it’s not a fix yet). However, rather to extract the whole jar and modify many unnecessary files (shown in his instruction [a] and [b]), I chose to extract only the particular file, modify it and add it back to jar. Here’s what I did:

  1. Find livehttpheaders.jar – I’m using Win2k installed in C drive. So normally firefox keeps all extensions under C:\Document and Settings\Application Data\Mozilla\Firefox\Profiles\xxxxx.default\extensions directory. From there, you can find the livehttpheaders.jar file under {8f8fe09b-0bd3-4470-bc1b-8cad42b8203a}\chrome directory.
  2. Extract LiveHTTPHeaders.js with WinRAR – I think both WinRAR & Winzip will do the job. Just browse into the jar file, find LiveHTTPHeaders.js under content directory and extract it.
  3. Add two lines of code to LiveHTTPHeaders.js – as suggested by Daniel, quoted as below:
    // This is the observerService's observe listener.
    observe: function(aSubject, aTopic, aData) {
    +		if (typeof Components == 'undefined')
    +			return;
    if (aTopic == 'http-on-modify-request') {
    aSubject.QueryInterface(Components.interfaces.nsIHttpChannel);
    (added the lines with the + at the beginning,
    but add them without the +!)
  4. Add LiveHTTPHeaders.js back to livehttpheaders.jar - just drag & drop it back into the WinRAR window, WinRAR will do the job for you. BTW, make sure you close the firefox before you add the file, otherwise it will fail as firefox is using that jar file.

Yeah, that’s all! ;)

2 Comments

  1. Mark said,

    good stuff. Makes debugging nicer to do.

  2. amit srivastava said,

    thnx buddy it helped us alot :)

Post a Comment