moonbridge
diff moonbridge_http.lua @ 175:4cf337821a52
Minor code cleanup and changed default timeout values
author | jbe |
---|---|
date | Thu Jun 18 04:09:21 2015 +0200 (2015-06-18) |
parents | d6db92e0f231 |
children | b2d024220782 |
line diff
1.1 --- a/moonbridge_http.lua Wed Jun 17 23:50:28 2015 +0200 1.2 +++ b/moonbridge_http.lua Thu Jun 18 04:09:21 2015 +0200 1.3 @@ -132,7 +132,7 @@ 1.4 return nextvalue, params_list_mapping[self], nil 1.5 end 1.6 } 1.7 - -- returns a table to store key value-list pairs (i.e. multiple values), 1.8 + -- function that returns a table to store key value-list pairs, 1.9 -- and a second table automatically mapping keys to the first value 1.10 -- using the key value-list pairs in the first table: 1.11 new_params_list = function() 1.12 @@ -143,7 +143,7 @@ 1.13 end 1.14 end 1.15 1.16 --- parses URL encoded form data and stores it in 1.17 +-- function parsing URL encoded form data and storing it in 1.18 -- a key value-list pairs structure that has to be 1.19 -- previously obtained by calling by new_params_list(): 1.20 local function read_urlencoded_form(tbl, data) 1.21 @@ -153,15 +153,7 @@ 1.22 end 1.23 end 1.24 1.25 --- extracts first value from each subtable: 1.26 -local function get_first_values(tbl) 1.27 - local newtbl = {} 1.28 - for key, subtbl in pairs(tbl) do 1.29 - newtbl[key] = subtbl[1] 1.30 - end 1.31 - return newtbl 1.32 -end 1.33 - 1.34 +-- function to convert a HTTP request handler to a socket handler: 1.35 function generate_handler(handler, options) 1.36 -- swap arguments if necessary (for convenience): 1.37 if type(handler) ~= "function" and type(options) == "function" then 1.38 @@ -189,7 +181,7 @@ 1.39 t[#t+1] = line 1.40 end 1.41 else 1.42 - for i, kv in ipairs(options.static_headers) do 1.43 + for i, kv in ipairs(s) do 1.44 if type(kv) == "string" then 1.45 t[#t+1] = kv 1.46 else 1.47 @@ -205,9 +197,9 @@ 1.48 local output_chunk_size = options.minimum_output_chunk_size or options.chunk_size or 1024 1.49 local header_size_limit = options.header_size_limit or 1024*1024 1.50 local body_size_limit = options.body_size_limit or 64*1024*1024 1.51 - local request_idle_timeout = default("request_idle_timeout", 330) 1.52 + local request_idle_timeout = default("request_idle_timeout", 65) 1.53 local request_header_timeout = default("request_header_timeout", 30) 1.54 - local request_body_timeout = default("request_body_timeout", 60) 1.55 + local request_body_timeout = default("request_body_timeout", 300) 1.56 local response_timeout = default("response_timeout", 1800) 1.57 local poll = options.poll_function or moonbridge_io.poll 1.58 -- return socket handler: