title: XPCOM: sniff HTTP responses
body: <p>I would like to write a little component with XPCOM that can sniff all HTTP responses received by the browser. Right now the only examples that I can find (like the one appended below) only allow me to retrieve the response for a request that I fire myself:</p>
  
  <pre><code>var req = new XMLHttpRequest();  
  req.open('GET', 'http://www.mozilla.org/', true);  
  req.onreadystatechange = function (aEvt) {  
  if (req.readyState == 4) {  
      if(req.status == 200)  
          dump(req.responseText);  
          else  
          dump("Error loading page\n");  
      }  
  };
  </code></pre>
  
  <p>What I want is for any HTTP response that the browser receives get the HTTP headers of the corresponding request.</p>
  
  <p>Thanks  </p>