# HG changeset patch # User jbe # Date 1434593361 -7200 # Node ID 4cf337821a520add4d0f2c01be46fe5658822a9c # Parent d6db92e0f2314da21313126ef0e146473109555b Minor code cleanup and changed default timeout values diff -r d6db92e0f231 -r 4cf337821a52 moonbridge_http.lua --- a/moonbridge_http.lua Wed Jun 17 23:50:28 2015 +0200 +++ b/moonbridge_http.lua Thu Jun 18 04:09:21 2015 +0200 @@ -132,7 +132,7 @@ return nextvalue, params_list_mapping[self], nil end } - -- returns a table to store key value-list pairs (i.e. multiple values), + -- function that returns a table to store key value-list pairs, -- and a second table automatically mapping keys to the first value -- using the key value-list pairs in the first table: new_params_list = function() @@ -143,7 +143,7 @@ end end --- parses URL encoded form data and stores it in +-- function parsing URL encoded form data and storing it in -- a key value-list pairs structure that has to be -- previously obtained by calling by new_params_list(): local function read_urlencoded_form(tbl, data) @@ -153,15 +153,7 @@ end end --- extracts first value from each subtable: -local function get_first_values(tbl) - local newtbl = {} - for key, subtbl in pairs(tbl) do - newtbl[key] = subtbl[1] - end - return newtbl -end - +-- function to convert a HTTP request handler to a socket handler: function generate_handler(handler, options) -- swap arguments if necessary (for convenience): if type(handler) ~= "function" and type(options) == "function" then @@ -189,7 +181,7 @@ t[#t+1] = line end else - for i, kv in ipairs(options.static_headers) do + for i, kv in ipairs(s) do if type(kv) == "string" then t[#t+1] = kv else @@ -205,9 +197,9 @@ local output_chunk_size = options.minimum_output_chunk_size or options.chunk_size or 1024 local header_size_limit = options.header_size_limit or 1024*1024 local body_size_limit = options.body_size_limit or 64*1024*1024 - local request_idle_timeout = default("request_idle_timeout", 330) + local request_idle_timeout = default("request_idle_timeout", 65) local request_header_timeout = default("request_header_timeout", 30) - local request_body_timeout = default("request_body_timeout", 60) + local request_body_timeout = default("request_body_timeout", 300) local response_timeout = default("response_timeout", 1800) local poll = options.poll_function or moonbridge_io.poll -- return socket handler: