From 4821fe086bdad1100cd5a2c6a8d5002205854559 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 18 Mar 2021 11:30:57 +0100 Subject: [PATCH] More robust logic in case of missing HTTP version on the logged request --- platypush/backend/log/http.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platypush/backend/log/http.py b/platypush/backend/log/http.py index 6ae76d223..91b36bd7d 100644 --- a/platypush/backend/log/http.py +++ b/platypush/backend/log/http.py @@ -100,6 +100,13 @@ class LogEventHandler(EventHandler): logger.warning('Could not parse log line from {}: {}'.format(file, line)) return + http_version = '1.0' + version_string = m.group(5).split(' ') + if version_string: + version_string = version_string[2].split('/') + if version_string: + http_version = version_string[1] + info = { 'address': m.group(1), 'user_identifier': m.group(2), @@ -107,7 +114,7 @@ class LogEventHandler(EventHandler): 'time': datetime.datetime.strptime(m.group(4), '%d/%b/%Y:%H:%M:%S %z'), 'method': m.group(5).split(' ')[0], 'url': m.group(5).split(' ')[1], - 'http_version': m.group(5).split(' ')[2].split('/')[1], + 'http_version': http_version, 'status': int(m.group(6)), 'size': int(m.group(7)), 'referrer': m.group(9),