From cba1fd6930f33b76d157692f1481f6fc8330c77a Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Sat, 29 Apr 2023 13:36:12 +0200 Subject: [PATCH] Fix #9685 Date is not a content header (#9687) resetContent does not reset Date Header Signed-off-by: gregw --- .../src/main/java/org/eclipse/jetty/server/Response.java | 1 - .../test/java/org/eclipse/jetty/server/ErrorHandlerTest.java | 1 + .../src/test/java/org/eclipse/jetty/server/ResponseTest.java | 2 ++ 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java index d2eb39e9ef1..53eda402ad3 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java @@ -1253,7 +1253,6 @@ public class Response implements HttpServletResponse case LAST_MODIFIED: case EXPIRES: case ETAG: - case DATE: case VARY: i.remove(); continue; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ErrorHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ErrorHandlerTest.java index 98e3da73a78..85cf2ae1d5e 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ErrorHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ErrorHandlerTest.java @@ -154,6 +154,7 @@ public class ErrorHandlerTest assertThat("Response status code", response.getStatus(), is(404)); assertThat("Response Content-Length", response.getField(HttpHeader.CONTENT_LENGTH).getIntValue(), greaterThan(0)); assertThat("Response Content-Type", response.get(HttpHeader.CONTENT_TYPE), containsString("text/html;charset=ISO-8859-1")); + assertThat(response.get(HttpHeader.DATE), notNullValue()); assertThat(response.getContent(), containsString("content=\"text/html;charset=ISO-8859-1\"")); assertContent(response); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java index d6f2029229a..e34321baeae 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java @@ -2090,6 +2090,7 @@ public class ResponseTest response.setContentType("some/type"); response.setContentLength(3); response.setHeader(HttpHeader.EXPIRES, "never"); + response.setHeader(HttpHeader.DATE, "2000-01-01"); response.setHeader("SomeHeader", "SomeValue"); @@ -2106,6 +2107,7 @@ public class ResponseTest // check arbitrary header still set assertThat(response.getHeader("SomeHeader"), is("SomeValue")); + assertThat(response.getHeader("Date"), is("2000-01-01")); // check cookies are still there Enumeration set = response.getHttpFields().getValues("Set-Cookie");