Software /
code /
prosody
Comparison
net/http/server.lua @ 7579:d430573fe9f8
net.http.server: Expose way to set http server options
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 18 Aug 2016 14:50:39 +0200 |
parent | 6589:015f2b4e2f9a |
child | 7581:01d0d466d7be |
comparison
equal
deleted
inserted
replaced
7578:65bf55fdf971 | 7579:d430573fe9f8 |
---|---|
17 | 17 |
18 local sessions = {}; | 18 local sessions = {}; |
19 local listener = {}; | 19 local listener = {}; |
20 local hosts = {}; | 20 local hosts = {}; |
21 local default_host; | 21 local default_host; |
22 local options = {}; | |
22 | 23 |
23 local function is_wildcard_event(event) | 24 local function is_wildcard_event(event) |
24 return event:sub(-2, -1) == "/*"; | 25 return event:sub(-2, -1) == "/*"; |
25 end | 26 end |
26 local function is_wildcard_match(wildcard_event, event) | 27 local function is_wildcard_match(wildcard_event, event) |
128 -- FIXME don't close immediately, wait until we process current stuff | 129 -- FIXME don't close immediately, wait until we process current stuff |
129 -- FIXME if err, send off a bad-request response | 130 -- FIXME if err, send off a bad-request response |
130 sessions[conn] = nil; | 131 sessions[conn] = nil; |
131 conn:close(); | 132 conn:close(); |
132 end | 133 end |
133 sessions[conn] = parser_new(success_cb, error_cb); | 134 local function options_cb() |
135 return options; | |
136 end | |
137 sessions[conn] = parser_new(success_cb, error_cb, "server", options_cb); | |
134 end | 138 end |
135 | 139 |
136 function listener.ondisconnect(conn) | 140 function listener.ondisconnect(conn) |
137 local open_response = conn._http_open_response; | 141 local open_response = conn._http_open_response; |
138 if open_response and open_response.on_destroy then | 142 if open_response and open_response.on_destroy then |
298 default_host = host; | 302 default_host = host; |
299 end | 303 end |
300 function _M.fire_event(event, ...) | 304 function _M.fire_event(event, ...) |
301 return events.fire_event(event, ...); | 305 return events.fire_event(event, ...); |
302 end | 306 end |
307 function _M.set_option(name, value) | |
308 options[name] = value; | |
309 end | |
303 | 310 |
304 _M.listener = listener; | 311 _M.listener = listener; |
305 _M.codes = codes; | 312 _M.codes = codes; |
306 _M._events = events; | 313 _M._events = events; |
307 return _M; | 314 return _M; |