1 -- Licensed to the Apache Software Foundation (ASF) under one or more
2 -- contributor license agreements. See the NOTICE file distributed with
3 -- this work for additional information regarding copyright ownership.
4 -- The ASF licenses this file to You under the Apache License, Version 2.0
5 -- (the "License"); you may not use this file except in compliance with
6 -- the License. You may obtain a copy of the License at
8 -- http://www.apache.org/licenses/LICENSE-2.0
10 -- Unless required by applicable law or agreed to in writing, software
11 -- distributed under the License is distributed on an "AS IS" BASIS,
12 -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 -- See the License for the specific language governing permissions and
14 -- limitations under the License.
18 function print_args(r
, simple
, complex
)
21 for k
, v
in pairs(simple
) do
22 r
:puts(s
:format(k
, v
))
27 for k
, ary
in pairs(complex
) do
31 if i
< #ary
then r
:puts(", ") end
37 function debug_stuff(r
)
38 r
:debug("This is a debug log message")
39 -- r:info("This is an info log message")
40 -- r:notice("This is an notice log message")
41 -- r:warn("This is an warn log message")
42 -- r:err("This is an err log message")
43 -- r:alert("This is an alert log message")
44 -- r:crit("This is an crit log message")
45 -- r:emerg("This is an emerg log message")
49 r
:puts("hello Lua world\n")
50 r
:puts("Query args:\n")
52 print_args(r
, r
:parseargs());
56 r
:puts("HTTP Method:\n " .. r
.method
.. "\n")
58 if r
.method
== 'POST' then
59 print_args(r
, r
:parsebody())
63 r
:puts("loaded relative to script:\n ")
66 r
:puts("loaded from LuaPackagePath:\n")
71 function handle_foo(r
)
72 r
:puts("Handler FOO!\n")
74 r
:debug("set status to 201")
78 function handle_attributes(r
)
79 local function pf(name
)
80 r
:puts(("%s: %s\n"):format(name
, tostring(r
[name
])))
89 r
.content_type
= "text/plain?charset=ascii"
98 pf("content_encoding")
104 pf("canonical_filename")
111 function test_headers(r
)
112 r
:puts("test getting and setting headers here\n")
115 function handle_quietly(r
)
119 function handle_regex(r
)
120 r
:puts("matched in handle_regex")
123 function handle_serverversion(r
)
124 r
:puts(apache2
.version
)
127 function handle_fixupstest(r
)
128 r
:puts("status is " .. r
.status
)