webmcp
diff framework/env/request/handler.lua @ 328:04b0687130d8
Bugfix regarding request_per_connection counting; Use new :close_after_finish() method of Moonbridge
author | jbe |
---|---|
date | Tue Mar 24 01:58:17 2015 +0100 (2015-03-24) |
parents | d8480a60a07d |
children | 3db9b672ee73 |
line diff
1.1 --- a/framework/env/request/handler.lua Tue Mar 24 01:08:32 2015 +0100 1.2 +++ b/framework/env/request/handler.lua Tue Mar 24 01:58:17 2015 +0100 1.3 @@ -2,7 +2,6 @@ 1.4 success = -- false if an error occurred, true otherwise 1.5 request.handler( 1.6 http_request, -- HTTP request object 1.7 - close -- boolean indicating whether the server should announce to close the connection 1.8 ) 1.9 1.10 Called by mcp.lua to process an HTTP request. Calls request.router(), and handles the request. Note: request initializers will have to be (automatically) executed before this function is invoked by mcp.lua. 1.11 @@ -20,7 +19,6 @@ 1.12 end 1.13 1.14 function request.handler(http_request, close) 1.15 - local close_sent = false 1.16 request._http_request = http_request 1.17 local path = http_request.path 1.18 if path then 1.19 @@ -44,19 +42,14 @@ 1.20 end 1.21 end 1.22 1.23 - if close then 1.24 - request.add_header("Connection", "close") 1.25 - close_sent = true 1.26 - end 1.27 - 1.28 local success, error_info = xpcall( 1.29 function() 1.30 1.31 if request._route.static then 1.32 local f, errmsg = io.open(WEBMCP_BASE_PATH .. "static/" .. request._route.static, "r") 1.33 if not f then 1.34 + request.set_status("404 Not Found") 1.35 if request.get_404_route() then 1.36 - request.set_status("404 Not Found") 1.37 request.forward(request.get_404_route()) 1.38 else 1.39 error('Could not open static file "' .. request._route.static .. '": ' .. errmsg) 1.40 @@ -208,9 +201,7 @@ 1.41 if not request._status then 1.42 request._status = "500 Internal Server Error" 1.43 end 1.44 - if not close_sent then 1.45 - request.add_header("Connection", "close") 1.46 - end 1.47 + http_request:close_after_finish() 1.48 slot.set_layout('system_error') 1.49 slot.select('system_error', function() 1.50 if getmetatable(errobj) == mondelefant.errorobject_metatable then