summaryrefslogtreecommitdiffstats
path: root/modules/lua/test/htdocs
diff options
context:
space:
mode:
Diffstat (limited to 'modules/lua/test/htdocs')
-rw-r--r--modules/lua/test/htdocs/config_tests.lua37
-rw-r--r--modules/lua/test/htdocs/filters.lua7
-rw-r--r--modules/lua/test/htdocs/find_me.txt1
-rw-r--r--modules/lua/test/htdocs/headers.lua6
-rw-r--r--modules/lua/test/htdocs/hooks.lua29
-rw-r--r--modules/lua/test/htdocs/other.lua21
-rw-r--r--modules/lua/test/htdocs/simple.lua4
-rw-r--r--modules/lua/test/htdocs/test.lua129
8 files changed, 234 insertions, 0 deletions
diff --git a/modules/lua/test/htdocs/config_tests.lua b/modules/lua/test/htdocs/config_tests.lua
new file mode 100644
index 0000000..698bedf
--- /dev/null
+++ b/modules/lua/test/htdocs/config_tests.lua
@@ -0,0 +1,37 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+require 'string'
+
+local count = 0
+
+function handle(r)
+ r:puts("success in handle " .. count)
+end
+
+function handle_server_vm(r)
+ r:puts("hello from server scope " .. count)
+ count = count + 1
+end
+
+function handle_request_vm(r)
+ r:puts("hello from request scope " .. count)
+ count = count + 1
+end
+
+function handle_conn_vm(r)
+ r:puts("hello from request scope " .. count)
+ count = count + 1
+end \ No newline at end of file
diff --git a/modules/lua/test/htdocs/filters.lua b/modules/lua/test/htdocs/filters.lua
new file mode 100644
index 0000000..cad0ca8
--- /dev/null
+++ b/modules/lua/test/htdocs/filters.lua
@@ -0,0 +1,7 @@
+
+local s = require 'string'
+
+function handle_simple(r)
+ -- r:addoutputfilter("wombathood")
+ r:puts("added wombathood")
+end \ No newline at end of file
diff --git a/modules/lua/test/htdocs/find_me.txt b/modules/lua/test/htdocs/find_me.txt
new file mode 100644
index 0000000..cb96e9e
--- /dev/null
+++ b/modules/lua/test/htdocs/find_me.txt
@@ -0,0 +1 @@
+please find me \ No newline at end of file
diff --git a/modules/lua/test/htdocs/headers.lua b/modules/lua/test/htdocs/headers.lua
new file mode 100644
index 0000000..35938ea
--- /dev/null
+++ b/modules/lua/test/htdocs/headers.lua
@@ -0,0 +1,6 @@
+function handle(r)
+ local host = r.headers_in['host']
+ r:debug(host)
+ r:puts(host)
+ r.headers_out['wombat'] = 'lua'
+end
diff --git a/modules/lua/test/htdocs/hooks.lua b/modules/lua/test/htdocs/hooks.lua
new file mode 100644
index 0000000..b8a8248
--- /dev/null
+++ b/modules/lua/test/htdocs/hooks.lua
@@ -0,0 +1,29 @@
+require 'string'
+require 'apache2'
+
+function translate_name(r)
+ if r.uri == "/translate-name" then
+ r.uri = "/find_me.txt"
+ return apache2.DECLINED
+ end
+ return apache2.DECLINED
+end
+
+function translate_name2(r)
+ if r.uri == "/translate-name2" then
+ r.uri = "/find_me.txt"
+ return apache2.DECLINED
+ end
+ return apache2.DECLINED
+end
+
+function fixups_test(r)
+ -- r:err("KABAZ")
+ if r.uri == "/test_fixupstest" then
+ -- r:err("KABIZ")
+ r.status = 201
+ return apache2.OK
+ end
+ -- r:err("ZIBAK")
+ return apache2.DECLINED
+end \ No newline at end of file
diff --git a/modules/lua/test/htdocs/other.lua b/modules/lua/test/htdocs/other.lua
new file mode 100644
index 0000000..90c6ed2
--- /dev/null
+++ b/modules/lua/test/htdocs/other.lua
@@ -0,0 +1,21 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+module("other")
+
+function doit(r)
+ r:debug("doing it...")
+ r:puts("Do It!\n")
+end
diff --git a/modules/lua/test/htdocs/simple.lua b/modules/lua/test/htdocs/simple.lua
new file mode 100644
index 0000000..a3f8861
--- /dev/null
+++ b/modules/lua/test/htdocs/simple.lua
@@ -0,0 +1,4 @@
+function handle(r)
+ r.content_type = "text/plain"
+ r:puts("Hi there!")
+end
diff --git a/modules/lua/test/htdocs/test.lua b/modules/lua/test/htdocs/test.lua
new file mode 100644
index 0000000..c0b96ab
--- /dev/null
+++ b/modules/lua/test/htdocs/test.lua
@@ -0,0 +1,129 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+require 'string'
+
+function print_args(r, simple, complex)
+ local s = " %s: %s\n"
+ r:puts(" simple:\n")
+ for k, v in pairs(simple) do
+ r:puts(s:format(k, v))
+ end
+
+ s = " %s: "
+ r:puts(" complex:\n")
+ for k, ary in pairs(complex) do
+ r:puts(s:format(k))
+ for i=1, #ary do
+ r:puts(ary[i])
+ if i < #ary then r:puts(", ") end
+ end
+ r:puts("\n")
+ end
+end
+
+function debug_stuff(r)
+ r:debug("This is a debug log message")
+ -- r:info("This is an info log message")
+ -- r:notice("This is an notice log message")
+ -- r:warn("This is an warn log message")
+ -- r:err("This is an err log message")
+ -- r:alert("This is an alert log message")
+ -- r:crit("This is an crit log message")
+ -- r:emerg("This is an emerg log message")
+end
+
+function handle(r)
+ r:puts("hello Lua world\n")
+ r:puts("Query args:\n")
+
+ print_args(r, r:parseargs());
+
+ debug_stuff(r)
+
+ r:puts("HTTP Method:\n " .. r.method .. "\n")
+
+ if r.method == 'POST' then
+ print_args(r, r:parsebody())
+ end
+
+ require("other")
+ r:puts("loaded relative to script:\n ")
+ other.doit(r)
+
+ r:puts("loaded from LuaPackagePath:\n")
+ require("kangaroo");
+ kangaroo.hop(r);
+end
+
+function handle_foo(r)
+ r:puts("Handler FOO!\n")
+ r.status = 201
+ r:debug("set status to 201")
+end
+
+
+function handle_attributes(r)
+ local function pf(name)
+ r:puts(("%s: %s\n"):format(name, tostring(r[name])))
+ end
+
+ pf("status")
+ r.status = 201
+ pf("status")
+ r:puts("\n")
+
+ pf("content_type")
+ r.content_type = "text/plain?charset=ascii"
+ pf("content_type")
+ r:puts("\n")
+
+ pf("method")
+ pf("protocol")
+ pf("assbackwards")
+ pf("the_request")
+ pf("range")
+ pf("content_encoding")
+ pf("user")
+ pf("unparsed_uri")
+ pf("ap_auth_type")
+ pf("uri")
+ pf("filename")
+ pf("canonical_filename")
+ pf("path_info")
+ pf("args")
+
+ r:puts("\n")
+end
+
+function test_headers(r)
+ r:puts("test getting and setting headers here\n")
+end
+
+function handle_quietly(r)
+ r:puts("hello!")
+end
+
+function handle_regex(r)
+ r:puts("matched in handle_regex")
+end
+
+function handle_serverversion(r)
+ r:puts(apache2.version)
+end
+
+function handle_fixupstest(r)
+ r:puts("status is " .. r.status)
+end \ No newline at end of file