Add support for xff header in verbose web logger

This commit is contained in:
Lukas Rieger (Blue) 2023-06-29 08:29:53 +02:00
parent 1b26811c6a
commit 4141d21a70
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2

View File

@ -1,5 +1,6 @@
package de.bluecolored.bluemap.common.web;
import de.bluecolored.bluemap.common.web.http.HttpHeader;
import de.bluecolored.bluemap.common.web.http.HttpRequest;
import de.bluecolored.bluemap.common.web.http.HttpRequestHandler;
import de.bluecolored.bluemap.common.web.http.HttpResponse;
@ -21,7 +22,14 @@ public LoggingRequestHandler(HttpRequestHandler delegate, Logger logger) {
@Override
public HttpResponse handle(HttpRequest request) {
String log = request.getSource() + " \""
String source = request.getSource().toString();
HttpHeader xffHeader = request.getHeader("x-forwarded-for");
if (xffHeader != null && !xffHeader.getValues().isEmpty()) {
source = xffHeader.getValues().get(0);
}
String log = source + " \""
+ request.getMethod()
+ " " + request.getAddress()
+ " " + request.getVersion()