# HG changeset patch # User Kim Alvefur # Date 1522409859 -7200 # Node ID 569b98d6fca1fad809ddfe8755a2a34999854309 # Parent 135ca695fcbfc0865a3eefcbed2022c625c2b093 mod_http_logging: Be robust against missing connection object diff -r 135ca695fcbf -r 569b98d6fca1 mod_http_logging/mod_http_logging.lua --- 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);