Software /
code /
prosody
Comparison
net/http/server.lua @ 7581:01d0d466d7be
Merge 0.9->0.10
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 18 Aug 2016 15:16:02 +0200 |
parent | 7541:1d3f9da189b5 |
parent | 7579:d430573fe9f8 |
child | 7582:e080b8b4f3cb |
comparison
equal
deleted
inserted
replaced
7572:f549587b8c06 | 7581:01d0d466d7be |
---|---|
20 local sessions = {}; | 20 local sessions = {}; |
21 local incomplete = {}; | 21 local incomplete = {}; |
22 local listener = {}; | 22 local listener = {}; |
23 local hosts = {}; | 23 local hosts = {}; |
24 local default_host; | 24 local default_host; |
25 local options = {}; | |
25 | 26 |
26 local function is_wildcard_event(event) | 27 local function is_wildcard_event(event) |
27 return event:sub(-2, -1) == "/*"; | 28 return event:sub(-2, -1) == "/*"; |
28 end | 29 end |
29 local function is_wildcard_match(wildcard_event, event) | 30 local function is_wildcard_match(wildcard_event, event) |
131 -- FIXME don't close immediately, wait until we process current stuff | 132 -- FIXME don't close immediately, wait until we process current stuff |
132 -- FIXME if err, send off a bad-request response | 133 -- FIXME if err, send off a bad-request response |
133 sessions[conn] = nil; | 134 sessions[conn] = nil; |
134 conn:close(); | 135 conn:close(); |
135 end | 136 end |
136 sessions[conn] = parser_new(success_cb, error_cb); | 137 local function options_cb() |
138 return options; | |
139 end | |
140 sessions[conn] = parser_new(success_cb, error_cb, "server", options_cb); | |
137 end | 141 end |
138 | 142 |
139 function listener.ondisconnect(conn) | 143 function listener.ondisconnect(conn) |
140 local open_response = conn._http_open_response; | 144 local open_response = conn._http_open_response; |
141 if open_response and open_response.on_destroy then | 145 if open_response and open_response.on_destroy then |
348 default_host = host; | 352 default_host = host; |
349 end | 353 end |
350 function _M.fire_event(event, ...) | 354 function _M.fire_event(event, ...) |
351 return events.fire_event(event, ...); | 355 return events.fire_event(event, ...); |
352 end | 356 end |
357 function _M.set_option(name, value) | |
358 options[name] = value; | |
359 end | |
353 | 360 |
354 _M.listener = listener; | 361 _M.listener = listener; |
355 _M.codes = codes; | 362 _M.codes = codes; |
356 _M._events = events; | 363 _M._events = events; |
357 return _M; | 364 return _M; |