r9695 - helma-ng/trunk/modules/helma/webapp

[email protected] Mon, 4 May 2009 11:07:20 +0200 (CEST)
Newsgroups gmane.comp.java.helma.cvs
Message-ID <20090504090720.5634B3D0D6@mia>
Author: hannes
Date: 2009-05-04 11:07:20 +0200 (Mon, 04 May 2009)
New Revision: 9695

Modified:
   helma-ng/trunk/modules/helma/webapp/util.js
Log:
Add ResponseFilter class to helma/webapp/util to easily apply filters to jack response bodies.

Details at http://dev.helma.org/trac/helma/changeset/9695

Modified: helma-ng/trunk/modules/helma/webapp/util.js
===================================================================
--- helma-ng/trunk/modules/helma/webapp/util.js	2009-04-30 20:07:20 UTC (rev 9694)
+++ helma-ng/trunk/modules/helma/webapp/util.js	2009-05-04 09:07:20 UTC (rev 9695)
@@ -1,5 +1,16 @@
 require('core/string');
 
+exports.ResponseFilter = function(body, filter) {
+    this.forEach = function(fn) {
+        body.forEach(function(block) {
+            var filtered = filter(block);
+            if (filtered != null) {
+                fn(filtered);
+            }
+        });
+    };
+};
+
 exports.getSubHeader = function(headerValue, subHeaderName) {
     if (!headerValue)
         return null;
@@ -14,4 +25,4 @@
         }
     }
     return null;
-}
\ No newline at end of file
+};