[Livehttpheaders] Filter by row

Bob Farrell bob.farrell at phgroup.com
Mon Oct 13 06:55:29 PDT 2008


Hello,

Well, we use livehttpheaders here a lot for various things and stuff, but I was
nothing short of overwhelmed with the amount of data being flushed out. My poor
synapses simlpy could not process all that data fast enough !

So, I've added a thing that lets you filter each row with a regex. I think I've
conformed to the same style as the rest of the code and it's only a few lines.
Please find attached a "cvs diff" and "cvs diff -u" both done from the root
directory; let me know if you want something better.

Bang bang,
-- 
--------------------------
Bob Farrell
pH, an Experian Company
www.phgroup.com
Office Line: 020 7598 0310
Fax: 020 7598 0311
--------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filter_rows.diff
Type: text/x-diff
Size: 2223 bytes
Desc: not available
URL: <http://www.mozdev.org/pipermail/livehttpheaders/attachments/20081013/17de4924/attachment.bin>
-------------- next part --------------
? filter_rows.diff
? filter_rows.unified_diff
? tmp
? content/.LiveHTTPHeaders.js.swp
? content/.LiveHTTPHeaders.xul.swp
Index: content/LiveHTTPHeaders.js
===================================================================
RCS file: /cvs/livehttpheaders/src/content/LiveHTTPHeaders.js,v
retrieving revision 1.10
diff -u -r1.10 LiveHTTPHeaders.js
--- content/LiveHTTPHeaders.js	24 May 2008 14:29:31 -0000	1.10
+++ content/LiveHTTPHeaders.js	13 Oct 2008 13:47:29 -0000
@@ -29,6 +29,7 @@
 // - observeResponse(uri, request, response, postData, isRedirect)
 
 var oHeaderInfoLive;
+
 function startHeaderInfoLive() {
   oHeaderInfoLive = new HeaderInfoLive();
   oHeaderInfoLive.start();
@@ -94,6 +95,8 @@
   this.filterRegexp  = this.getCharPref(this.lpref, "filterRegexp",'/$|\.html$'); // Filter mode
   this.useexclude  = this.getBoolPref(this.lpref, "exclude", false); // exclude mode
   this.excludeRegexp  = this.getCharPref(this.lpref, "excludeRegexp",'\.gif$|\.jpg$|\.ico$|\.css$|\.js$'); // exclude mode
+  this.useRowFilter = this.getCharPref(this.lpref, "useRowFilter", false);
+  this.rowFilterRegexp = this.getCharPref(this.lpref, "rowFilterRegexp", '');
 }
 HeaderInfoLive.prototype =
 {
@@ -180,6 +183,9 @@
 
   // Tree utility functions
   addRow: function(row, type) { 
+    if ((type != this.SEPARATOR) && this.useRowFilter && !row.match(this.rowFilterRegexp)) {
+        return;
+    }
     // Compute the style
     var style;
     if (this.rows>0) {
@@ -372,6 +378,8 @@
         document.getElementById("headerinfo-filterRegexp").value=this.filterRegexp;
         document.getElementById("headerinfo-exclude").checked=this.useexclude;
         document.getElementById("headerinfo-excludeRegexp").value=this.excludeRegexp;
+        document.getElementById("headerinfo-rowFilterRegexp").value=this.rowFilterRegexp;
+        document.getElementById("headerinfo-rowFilter").checked=this.useRowFilter;
     } catch (ex) {}
 
     // Set scrollbar
@@ -603,6 +611,14 @@
   setTab : function(tab) {
     this.setBoolPref(this.lpref, "tab", tab);
   },
+  setRowFilter : function(filter) {
+    this.setBoolPref(this.lpref, "rowFilter", filter);
+    this.useRowFilter = filter;
+  },
+  setRowFilterRegexp : function(regex) {
+    this.setCharPref(this.lpref, "rowFilterRegexp", regex);
+    this.rowFilterRegexp = regex;
+  },
   setFilter : function(filter) {
     this.setBoolPref(this.lpref, "filter", filter);
     this.usefilter = filter;
Index: content/LiveHTTPHeaders.xul
===================================================================
RCS file: /cvs/livehttpheaders/src/content/LiveHTTPHeaders.xul,v
retrieving revision 1.17
diff -u -r1.17 LiveHTTPHeaders.xul
--- content/LiveHTTPHeaders.xul	12 May 2008 04:49:14 -0000	1.17
+++ content/LiveHTTPHeaders.xul	13 Oct 2008 13:47:29 -0000
@@ -158,6 +158,14 @@
       	value="" oninput="oHeaderInfoLive.setFilterRegexp(this.value)"/>
     </hbox>
     <hbox>
+      <checkbox id="headerinfo-rowFilter"
+              label="&livehttpheaders.config.userowfilter;" checked="false"
+              tooltiptext="&livehttpheaders.config.userowfilter.tips;"
+              oncommand="oHeaderInfoLive.setRowFilter(this.checked)" />
+      <textbox id="headerinfo-rowFilterRegexp" flex="1"
+      	value="" oninput="oHeaderInfoLive.setRowFilterRegexp(this.value)"/>
+    </hbox>
+    <hbox>
       <checkbox id="headerinfo-exclude"
               label="&livehttpheaders.config.useexclude;" checked="false"
               tooltiptext="&livehttpheaders.config.useexclude.tips;"
Index: locale/en-US/livehttpheaders/livehttpheaders.dtd
===================================================================
RCS file: /cvs/livehttpheaders/src/locale/en-US/livehttpheaders/livehttpheaders.dtd,v
retrieving revision 1.17
diff -u -r1.17 livehttpheaders.dtd
--- locale/en-US/livehttpheaders/livehttpheaders.dtd	24 May 2008 14:29:32 -0000	1.17
+++ locale/en-US/livehttpheaders/livehttpheaders.dtd	13 Oct 2008 13:47:30 -0000
@@ -18,6 +18,8 @@
 <!ENTITY livehttpheaders.config.post "POST:">
 <!ENTITY livehttpheaders.config.usefilter "Filter URLs with regexp">
 <!ENTITY livehttpheaders.config.usefilter.tips "This filter applies to URL and not to each headers.">
+<!ENTITY livehttpheaders.config.userowfilter "Filter rows with regexp">
+<!ENTITY livehttpheaders.config.userowfilter.tips "Use this regex to filter individual rows">
 <!ENTITY livehttpheaders.config.useexclude "Exclude URLs with regexp">
 <!ENTITY livehttpheaders.config.useexclude.tips "This exclude applies to URL and not to each headers.">
 <!ENTITY livehttpheaders.config.addsidebar "Add LiveHTTPHeaders to sidebar">


More information about the Livehttpheaders mailing list