webmcp
diff framework/env/request/handler.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 | c3d539e33710 |
children | 56d237b81c18 |
line diff
1.1 --- a/framework/env/request/handler.lua Tue Mar 17 19:27:58 2015 +0100 1.2 +++ b/framework/env/request/handler.lua Fri Mar 20 05:30:57 2015 +0100 1.3 @@ -1,6 +1,7 @@ 1.4 --[[-- 1.5 request.handler( 1.6 - request -- HTTP request object 1.7 + request, -- HTTP request object 1.8 + close -- boolean indicating whether the server should announce to close the connection 1.9 ) 1.10 1.11 Called by mcp.lua to process an HTTP request. Performs some initializations, calls request.router(), and handles the request. 1.12 @@ -18,7 +19,7 @@ 1.13 end 1.14 1.15 -- TODO: function incomplete yet 1.16 -function request.handler(http_request) 1.17 +function request.handler(http_request, close) 1.18 _G.app = {} -- may be overwritten or modified by request initializers 1.19 do 1.20 request._in_progress = true -- NOTE: must be set to true before initializer functions are called 1.21 @@ -40,6 +41,10 @@ 1.22 end 1.23 request._route = request.router() or {} 1.24 1.25 + if close then 1.26 + request.add_header("Connection", "close") 1.27 + end 1.28 + 1.29 local success, error_info = xpcall( 1.30 function() 1.31 1.32 @@ -218,7 +223,9 @@ 1.33 redirect_params.tempstore = tempstore.save(slot_dump) 1.34 end 1.35 http_request:send_status("303 See Other") 1.36 - http_request:send_header("Connection", "close") -- TODO: extend moonbridge 1.37 + for i, header in ipairs(request._response_headers) do 1.38 + http_request:send_header(header[1], header[2]) 1.39 + end 1.40 http_request:send_header( 1.41 "Location", 1.42 encode.url{ 1.43 @@ -236,7 +243,6 @@ 1.44 if not success or not redirect_data then 1.45 1.46 http_request:send_status(request._status or "200 OK") 1.47 - http_request:send_header("Connection", "close") -- TODO: extend moonbridge 1.48 for i, header in ipairs(request._response_headers) do 1.49 http_request:send_header(header[1], header[2]) 1.50 end