Changeset

2968:569b98d6fca1

mod_http_logging: Be robust against missing connection object
author Kim Alvefur <zash@zash.se>
date Fri, 30 Mar 2018 13:37:39 +0200
parents 2967:135ca695fcbf
children 2969:8681729a47d5
files mod_http_logging/mod_http_logging.lua
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_http_logging/mod_http_logging.lua	Fri Mar 30 13:36:38 2018 +0200
+++ b/mod_http_logging/mod_http_logging.lua	Fri Mar 30 13:37:39 2018 +0200
@@ -24,7 +24,10 @@
 local function log_response(response, body)
 	local len = tostring(get_content_len(response, body) or "-");
 	local request = response.request;
-	local ip = request.ip or request.conn:ip();
+	local ip = request.ip;
+	if not ip and request.conn then
+		ip = request.conn:ip();
+	end
 	local req = string.format("%s %s HTTP/%s", request.method, request.path, request.httpversion);
 	local date = os.date("%d/%m/%Y:%H:%M:%S %z");
 	module:log("info", "%s - - [%s] \"%s\" %d %s", ip, date, req, response.status_code, len);