This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new fc7001a  eTags vary. Force HTTP/2 tests to use a constant value.
fc7001a is described below

commit fc7001a3da69608f98726883e03321eb6eddb50d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Sep 13 09:09:30 2019 +0100

    eTags vary. Force HTTP/2 tests to use a constant value.
---
 test/org/apache/coyote/http2/Http2TestBase.java       | 10 +++++++++-
 test/org/apache/coyote/http2/TestStreamProcessor.java |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/coyote/http2/Http2TestBase.java 
b/test/org/apache/coyote/http2/Http2TestBase.java
index 92ee6e0..a394927 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -51,6 +51,7 @@ import org.apache.coyote.http2.Http2Parser.Input;
 import org.apache.coyote.http2.Http2Parser.Output;
 import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.compat.JrePlatform;
+import org.apache.tomcat.util.http.FastHttpDateFormat;
 import org.apache.tomcat.util.http.MimeHeaders;
 
 /**
@@ -69,6 +70,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
     // test that demonstrated that most HTTP/2 tests were failing because the
     // response now included a date header
     protected static final String DEFAULT_DATE = "Wed, 11 Nov 2015 19:18:42 
GMT";
+    protected static final long DEFAULT_TIME = 
FastHttpDateFormat.parseDate(DEFAULT_DATE);
 
     private static final String HEADER_IGNORED = "x-ignore";
 
@@ -1022,9 +1024,15 @@ public abstract class Http2TestBase extends 
TomcatBaseTest {
 
         @Override
         public void emitHeader(String name, String value) {
-            // Date headers will always change so use a hard-coded default
             if ("date".equals(name)) {
+                // Date headers will always change so use a hard-coded default
                 value = DEFAULT_DATE;
+            } else if ("etag".equals(name) && value.startsWith("W/\"")) {
+                // etag headers will vary depending on when the source was
+                // checked out, unpacked, copied etc so use the same default as
+                // for date headers
+                int startOfTime = value.indexOf('-');
+                value = value.substring(0, startOfTime + 1) + DEFAULT_TIME + 
"\"";
             }
             // Some header values vary so ignore them
             if (HEADER_IGNORED.equals(name)) {
diff --git a/test/org/apache/coyote/http2/TestStreamProcessor.java 
b/test/org/apache/coyote/http2/TestStreamProcessor.java
index 821fa40..5f9651a 100644
--- a/test/org/apache/coyote/http2/TestStreamProcessor.java
+++ b/test/org/apache/coyote/http2/TestStreamProcessor.java
@@ -152,7 +152,7 @@ public class TestStreamProcessor extends Http2TestBase {
 
         Assert.assertEquals("3-HeadersStart\n" +
                 "3-Header-[:status]-[304]\n" +
-                "3-Header-[etag]-[W/\"934-1567674491000\"]\n" +
+                "3-Header-[etag]-[W/\"934-1447269522000\"]\n" +
                 "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
                 "3-HeadersEnd\n", output.getTrace());
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to