-
Notifications
You must be signed in to change notification settings - Fork 9
/
http_response.lua
33 lines (30 loc) · 918 Bytes
/
http_response.lua
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
27
28
29
30
31
32
33
return function(prototype, conn, ondisconnect)
------------------------------------------------------------------------------
-- add header (should be called before send)
------------------------------------------------------------------------------
local destructor = function(res)
res.conn = nil
res.headers = nil
res.addheader = nil
res.send = nil
res.sendfile = nil
res.sendredirect = nil
res.statuscode = nil
res.ondisconnect = nil
res.destructor = nil
end
------------------------------------------------------------------------------
-- send response
------------------------------------------------------------------------------
return {
conn = conn,
headers = {},
addheader = prototype.addheader,
send = prototype.send,
sendfile = prototype.sendfile,
sendredirect = prototype.sendredirect,
statuscode = 200,
close = ondisconnect,
destructor = destructor
}
end