File: setstatus.lua

package info (click to toggle)
haproxy 3.2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,924 kB
  • sloc: ansic: 267,927; sh: 3,466; xml: 1,756; python: 1,345; makefile: 1,155; perl: 168; cpp: 21
file content (26 lines) | stat: -rw-r--r-- 909 bytes parent folder | download | duplicates (7)
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)