summaryrefslogtreecommitdiffstats
path: root/tests/conf/setstatus.lua
blob: e2eafe12fbcb09879731c76f52a271f0f5a267d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-- http-response actions
core.register_action("set-status-418-defaultreason", {"http-res"}, function(txn)
	txn.http:res_set_status(418)
end)
core.register_action("set-status-418-customreason", {"http-res"}, function(txn)
	txn.http:res_set_status(418, "I'm a coffeepot")
end)

-- http services
core.register_service("http418-default", "http", function(applet)
   local response = "Hello World !"
   applet:set_status(418)
   applet:add_header("content-length", string.len(response))
   applet:add_header("content-type", "text/plain")
   applet:start_response()
   applet:send(response)
end)

core.register_service("http418-coffeepot", "http", function(applet)
   local response = "Hello World !"
   applet:set_status(418, "I'm a coffeepot")
   applet:add_header("content-length", string.len(response))
   applet:add_header("content-type", "text/plain")
   applet:start_response()
   applet:send(response)
end)