From 2e59500d695a51832452137f7cbfd3cb2a058d81 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 13 Jan 2022 17:56:21 +0100 Subject: [PATCH] Added asset filter in http visit definition. --- src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLog.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLog.java b/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLog.java index 4f9ee9f..1784ea5 100644 --- a/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLog.java +++ b/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLog.java @@ -21,6 +21,7 @@ package fr.devinsy.statoolinfos.metrics.http; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Locale; +import java.util.regex.Pattern; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,6 +36,8 @@ public class HttpAccessLog { private static Logger logger = LoggerFactory.getLogger(HttpAccessLog.class); + public static final Pattern ASSET_PATTERN = Pattern.compile("^.*\\.(avi|css|gif|ico|jpeg|jpg|js|mp3|mp4|ogg|png|svg|wav) HTTP.*$"); + private String ip; private String remoteUser; private LocalDateTime time; @@ -240,7 +243,8 @@ public class HttpAccessLog { boolean result; - if ((this.status.getCategory() == HttpStatusCategory.SUCCESS) && (!isBot()) && (this.request.startsWith("GET "))) + if ((this.status.getCategory() == HttpStatusCategory.SUCCESS) && (!isBot()) && (this.request.startsWith("GET ")) && + (!ASSET_PATTERN.matcher(this.request).matches())) { result = true; }