Add simplest possible test for lua output filtering.
git-svn-id: https://svn.apache.org/repos/asf/httpd/test/framework/trunk@1880665 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/t/conf/extra.conf.in b/t/conf/extra.conf.in
index cdde5db..21b7faa 100644
--- a/t/conf/extra.conf.in
+++ b/t/conf/extra.conf.in
@@ -1124,6 +1124,14 @@
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>
#
diff --git a/t/htdocs/modules/lua/filters.lua b/t/htdocs/modules/lua/filters.lua
new file mode 100644
index 0000000..4236ecc
--- /dev/null
+++ b/t/htdocs/modules/lua/filters.lua
@@ -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
diff --git a/t/modules/lua.t b/t/modules/lua.t
index 9eb5b4f..9e6836d 100644
--- a/t/modules/lua.t
+++ b/t/modules/lua.t
@@ -41,6 +41,8 @@
{ 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';