webmcp
diff framework/bin/mcp.lua @ 264:8aa38ddcc1b2
New configuration options "min_requests_per_connect" and "max_requests_per_connect"; Bugfix: Send headers added with request.add_header(...) also in case of 303 Redirect
author | jbe |
---|---|
date | Fri Mar 20 05:30:57 2015 +0100 (2015-03-20) |
parents | 1d2b463a65b0 |
children | 98537ccd0800 |
line diff
1.1 --- a/framework/bin/mcp.lua Tue Mar 17 19:27:58 2015 +0100 1.2 +++ b/framework/bin/mcp.lua Fri Mar 20 05:30:57 2015 +0100 1.3 @@ -211,17 +211,26 @@ 1.4 1.5 -- invoke moonbridge 1.6 if WEBMCP_MODE == "listen" then 1.7 + local http_options = request.get_http_options() 1.8 + local min_requests_per_connect = http_options.min_requests_per_connect or 90 1.9 + local max_requests_per_connect = http_options.max_requests_per_connect or 100 1.10 local http = require("moonbridge_http") 1.11 for i, listener in ipairs(listeners) do 1.12 + local request_count = 0 1.13 + local function inner_handler(request) 1.14 + request_count = request_count + 1 1.15 + request.handler(request, request_count >= max_requests_per_connect) 1.16 + end 1.17 + local outer_handler = http.generate_handler(inner_handler, http_options) 1.18 --listener.prepare = execute.postfork_initializers 1.19 listener.prepare = function() 1.20 _G.multirand = require "multirand" 1.21 execute.postfork_initializers() 1.22 end 1.23 - listener.connect = http.generate_handler( 1.24 - request.handler, 1.25 - request.get_http_options() 1.26 - ) 1.27 + listener.connect = function(socket) 1.28 + outer_handler(socket) 1.29 + return request_count < min_requests_per_connect 1.30 + end 1.31 listener.finish = execute.finalizers 1.32 moonbridge_listen(listener) 1.33 end