moonbridge
diff moonbridge_http.lua @ 54:e3df61bf62f4
Adjusted HTTP timeouts
author | jbe |
---|---|
date | Sun Mar 22 16:17:14 2015 +0100 (2015-03-22) |
parents | aaf67ef45c22 |
children | 7a385a440fa1 |
line diff
1.1 --- a/moonbridge_http.lua Sun Mar 22 13:19:54 2015 +0100 1.2 +++ b/moonbridge_http.lua Sun Mar 22 16:17:14 2015 +0100 1.3 @@ -178,32 +178,27 @@ 1.4 t[#t+1] = "" 1.5 preamble = table.concat(t, "\r\n") 1.6 end 1.7 - -- desired chunk sizes: 1.8 local input_chunk_size = options.maximum_input_chunk_size or options.chunk_size or 16384 1.9 local output_chunk_size = options.minimum_output_chunk_size or options.chunk_size or 1024 1.10 - -- timeouts: 1.11 - local request_header_timeout = options.http_request_header_timeout 1.12 - local request_body_timeout = options.http_request_body_timeout 1.13 - local request_timeout = options.http_request_timeout 1.14 - local response_timeout = options.http_timeout 1.15 - if request_header_timeout == nil then 1.16 - request_header_timeout = 60 1.17 + local request_header_timeout, response_timeout 1.18 + if options.request_header_timeout ~= nil then 1.19 + request_header_timeout = options.request_header_timeout 1.20 + elseif options.timeout ~= nil then 1.21 + request_header_timeout = options.timeout or 0 1.22 + else 1.23 + request_header_timeout = 360 1.24 end 1.25 - if response_timeout == nil then 1.26 - response_timeout = 60 1.27 + if options.timeout ~= nil then 1.28 + response_timeout = options.timeout or 0 1.29 + else 1.30 + response_timeout = 1800 1.31 end 1.32 -- return connect handler: 1.33 return function(socket) 1.34 local survive = true -- set to false if process shall be terminated later 1.35 repeat 1.36 - -- timeout management: 1.37 - if request_header_timeout then 1.38 - timeout(request_header_timeout) 1.39 - elseif request_timeout then 1.40 - timeout(request_timeout) 1.41 - else 1.42 - timeout(0) 1.43 - end 1.44 + -- (re)set timeout: 1.45 + timeout(request_header_timeout or 0) 1.46 -- process named arguments "request_header_size_limit" and "request_body_size_limit": 1.47 local remaining_header_size_limit = options.request_header_size_limit or 1024*1024 1.48 local remaining_body_size_limit = options.request_body_size_limit or 64*1024*1024 1.49 @@ -989,14 +984,7 @@ 1.50 request.cookies[decode_uri(rawkey)] = decode_uri(rawvalue) 1.51 end 1.52 end 1.53 - -- timeout management: 1.54 - if request_body_timeout then 1.55 - timeout(request_body_timeout) 1.56 - request:process_request_body() 1.57 - elseif request_timeout then 1.58 - timeout(request_timeout) 1.59 - request:process_request_body() 1.60 - end 1.61 + -- (re)set timeout: 1.62 timeout(response_timeout or 0) 1.63 -- call underlying handler and remember boolean result: 1.64 if handler(request) ~= true then survive = false end