From 369c2c05506cac2e96e972ea540c91da2bc05982 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 18 Aug 2016 14:50:39 +0200 Subject: net.http.server: Expose way to set http server options --- net/http/server.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'net/http/server.lua') diff --git a/net/http/server.lua b/net/http/server.lua index f091595c..32cda8aa 100644 --- a/net/http/server.lua +++ b/net/http/server.lua @@ -19,6 +19,7 @@ local sessions = {}; local listener = {}; local hosts = {}; local default_host; +local options = {}; local function is_wildcard_event(event) return event:sub(-2, -1) == "/*"; @@ -130,7 +131,10 @@ function listener.onconnect(conn) sessions[conn] = nil; conn:close(); end - sessions[conn] = parser_new(success_cb, error_cb); + local function options_cb() + return options; + end + sessions[conn] = parser_new(success_cb, error_cb, "server", options_cb); end function listener.ondisconnect(conn) @@ -300,6 +304,9 @@ end function _M.fire_event(event, ...) return events.fire_event(event, ...); end +function _M.set_option(name, value) + options[name] = value; +end _M.listener = listener; _M.codes = codes; -- cgit v1.2.3 From 33a8994b3cf6aabe428b7cdf6bba7bdf68d9c366 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 18 Aug 2016 15:21:30 +0200 Subject: net.http.server: Add luacheck annotations --- net/http/server.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'net/http/server.lua') diff --git a/net/http/server.lua b/net/http/server.lua index 93bbffb4..8aa28f5c 100644 --- a/net/http/server.lua +++ b/net/http/server.lua @@ -32,7 +32,7 @@ local function is_wildcard_match(wildcard_event, event) end local _handlers = events._handlers; -local recent_wildcard_events = cache.new(10000, function (key, value) +local recent_wildcard_events = cache.new(10000, function (key, value) -- luacheck: ignore 212/value rawset(_handlers, key, nil); end); @@ -174,7 +174,7 @@ local headerfix = setmetatable({}, { end }); -function _M.hijack_response(response, listener) +function _M.hijack_response(response, listener) -- luacheck: ignore error("TODO"); end function handle_request(conn, request, finish_cb) -- cgit v1.2.3