You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2020/08/07 10:08:04 UTC

svn commit: r1880665 - in /httpd/test/framework/trunk/t: conf/extra.conf.in htdocs/modules/lua/filters.lua modules/lua.t

Author: jorton
Date: Fri Aug  7 10:08:04 2020
New Revision: 1880665

URL: http://svn.apache.org/viewvc?rev=1880665&view=rev
Log:
Add simplest possible test for lua output filtering.

Added:
    httpd/test/framework/trunk/t/htdocs/modules/lua/filters.lua
Modified:
    httpd/test/framework/trunk/t/conf/extra.conf.in
    httpd/test/framework/trunk/t/modules/lua.t

Modified: httpd/test/framework/trunk/t/conf/extra.conf.in
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/conf/extra.conf.in?rev=1880665&r1=1880664&r2=1880665&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/conf/extra.conf.in (original)
+++ httpd/test/framework/trunk/t/conf/extra.conf.in Fri Aug  7 10:08:04 2020
@@ -1124,6 +1124,14 @@ LimitRequestFields    32
      LuaHookTranslateName @SERVERROOT@/htdocs/modules/lua/translate.lua translate_name2
      # default: LuaInherit parent-first
    </Location>
+
+   # Filtering tests
+   LuaOutputFilter LUA_OUTPUT @SERVERROOT@/htdocs/modules/lua/filters.lua output_filter
+   Alias /modules/lua/filtered @DocumentRoot@
+   <Location /modules/lua/filtered/>
+      SetOutputFilter LUA_OUTPUT
+   </Location>
+   
 </IfModule>
 
 # 

Added: httpd/test/framework/trunk/t/htdocs/modules/lua/filters.lua
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/htdocs/modules/lua/filters.lua?rev=1880665&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/htdocs/modules/lua/filters.lua (added)
+++ httpd/test/framework/trunk/t/htdocs/modules/lua/filters.lua Fri Aug  7 10:08:04 2020
@@ -0,0 +1,16 @@
+--[[
+    Example output filter that escapes all HTML entities in the output
+]]--
+function output_filter(r)
+    coroutine.yield("prefix\n")
+    while bucket do -- For each bucket, do...
+        if string.len(bucket) > 0 then
+            local output = "bucket:" .. bucket .. "\n"
+            coroutine.yield(output) -- Send converted data down the chain
+        else
+            coroutine.yield("") -- Send converted data down the chain
+        end
+    end
+    coroutine.yield("suffix\n")
+    -- No more buckets available.
+end

Modified: httpd/test/framework/trunk/t/modules/lua.t
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/lua.t?rev=1880665&r1=1880664&r2=1880665&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/modules/lua.t (original)
+++ httpd/test/framework/trunk/t/modules/lua.t Fri Aug  7 10:08:04 2020
@@ -41,6 +41,8 @@ my @ts = (
     { url => "$pfx/setheaderfromparam.lua?HeaderName=foo&HeaderValue=bar",
                                     rcontent => "Header set",
                                     headers => { "foo" => "bar" } },
+    { url => "$pfx/filtered/foobar.html",
+          rcontent => "prefix\nbucket:foobar\nsuffix\n" },
 );
 
 plan tests => 4 * scalar @ts, need 'lua';