diff --git a/core/src/main/java/io/undertow/UndertowOptions.java b/core/src/main/java/io/undertow/UndertowOptions.java index e8ef063dd4..b89eec6e77 100644 --- a/core/src/main/java/io/undertow/UndertowOptions.java +++ b/core/src/main/java/io/undertow/UndertowOptions.java @@ -171,6 +171,11 @@ public class UndertowOptions { */ public static final Option ALWAYS_SET_KEEP_ALIVE = Option.simple(UndertowOptions.class, "ALWAYS_SET_KEEP_ALIVE", Boolean.class); + /** + * Default value of {@link #ALWAYS_SET_DATE} option. + */ + public static final boolean DEFAULT_ALWAYS_SET_DATE = true; + /** * If this is true then a Date header will be added to all responses. The HTTP spec says this header should be added to all * responses, unless the server does not have an accurate clock. diff --git a/core/src/main/java/io/undertow/util/DateUtils.java b/core/src/main/java/io/undertow/util/DateUtils.java index 2df6cd0d37..3af21d78aa 100644 --- a/core/src/main/java/io/undertow/util/DateUtils.java +++ b/core/src/main/java/io/undertow/util/DateUtils.java @@ -236,7 +236,7 @@ public static boolean handleIfUnmodifiedSince(final String modifiedSince, final public static void addDateHeaderIfRequired(HttpServerExchange exchange) { HeaderMap responseHeaders = exchange.getResponseHeaders(); - if (exchange.getConnection().getUndertowOptions().get(UndertowOptions.ALWAYS_SET_DATE, true) && !responseHeaders.contains(Headers.DATE)) { + if (exchange.getConnection().getUndertowOptions().get(UndertowOptions.ALWAYS_SET_DATE, UndertowOptions.DEFAULT_ALWAYS_SET_DATE) && !responseHeaders.contains(Headers.DATE)) { String dateString = getCurrentDateTime(exchange); responseHeaders.put(Headers.DATE, dateString); }