You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/05/25 13:57:10 UTC

[tomcat] branch 10.1.x updated (21a5c1ddf7 -> b079eb4f84)

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

markt pushed a change to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


    from 21a5c1ddf7 Drop files Windows doesn't like.
     new 97d6ef12c0 Revert "Fix failing test. There should be no C-L for HEAD unless Servlet sets it"
     new b38281c826 Revert "Don't set 'C-L: 0' for HEAD requests if Servlet doesn't specify C-L"
     new b079eb4f84 Fix failing test.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/catalina/connector/OutputBuffer.java      | 6 +++---
 test/org/apache/catalina/servlets/TestDefaultServlet.java | 9 ---------
 webapps/docs/changelog.xml                                | 5 -----
 3 files changed, 3 insertions(+), 17 deletions(-)


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


[tomcat] 02/03: Revert "Don't set 'C-L: 0' for HEAD requests if Servlet doesn't specify C-L"

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b38281c8263d1a978594dd4e950f382bc7d96dba
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu May 25 14:15:09 2023 +0100

    Revert "Don't set 'C-L: 0' for HEAD requests if Servlet doesn't specify C-L"
    
    This reverts commit 7d9cacdfc2e073ef4b1493d14f5c8f9f47a00c7f.
    This broke too many things. It was also not quite right but even the correct
    fix broke quite a few tests.
    
    The fundamental problem is that Tomcat can't differentiate between a HEAD request
    that opts not to write any data to save resources (and should not have any C-L
    header) and a HEAD request explicitly writes zero byres because that is what the
    corresponding GET would do (which should have a header of C-L: 0).
    
    Rather than risk regressions, leave the current behaviour as-is.
---
 java/org/apache/catalina/connector/OutputBuffer.java | 6 +++---
 webapps/docs/changelog.xml                           | 5 -----
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/connector/OutputBuffer.java b/java/org/apache/catalina/connector/OutputBuffer.java
index 0e5bd6659e..62966c653b 100644
--- a/java/org/apache/catalina/connector/OutputBuffer.java
+++ b/java/org/apache/catalina/connector/OutputBuffer.java
@@ -232,9 +232,9 @@ public class OutputBuffer extends Writer {
             flushCharBuffer();
         }
 
-        if (!coyoteResponse.isCommitted() && coyoteResponse.getContentLengthLong() == -1 &&
-                !coyoteResponse.getRequest().method().equals("HEAD")) {
-            // If this didn't cause a commit of the response, the final content length can be calculated.
+        if ((!coyoteResponse.isCommitted()) && (coyoteResponse.getContentLengthLong() == -1)) {
+            // If this didn't cause a commit of the response, the final content
+            // length can be calculated.
             if (!coyoteResponse.isCommitted()) {
                 coyoteResponse.setContentLength(bb.remaining());
             }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index d7cc56b496..d1fe84b1d2 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -124,11 +124,6 @@
         file names in directory listings when using XML output. Based on pull
         request <pr>621</pr> by Alex Kachanov. (markt)
       </fix>
-      <fix>
-        When processing a HEAD request, do not set an HTTP response header for
-        Content-Length with the value zero if the Servlet does not set the
-        header. (markt)
-      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


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


[tomcat] 03/03: Fix failing test.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b079eb4f84828b389c1d5862fcc2aeb1abb2926e
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu May 25 14:37:36 2023 +0100

    Fix failing test.
    
    Content-length for HEAD is not reliable. We could have the default
    servlet return the correct value but that creates work for little/no
    value.
---
 test/org/apache/catalina/servlets/TestDefaultServlet.java | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/test/org/apache/catalina/servlets/TestDefaultServlet.java b/test/org/apache/catalina/servlets/TestDefaultServlet.java
index b67cc325d4..ab83f8ce17 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServlet.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServlet.java
@@ -633,13 +633,5 @@ public class TestDefaultServlet extends TomcatBaseTest {
 
         int rc = getUrl(path, out, resHeaders);
         Assert.assertEquals(HttpServletResponse.SC_OK, rc);
-        String length = resHeaders.get("Content-Length").get(0);
-        Assert.assertEquals(Long.parseLong(length), out.getLength());
-        out.recycle();
-
-        rc = headUrl(path, out, resHeaders);
-        Assert.assertEquals(HttpServletResponse.SC_OK, rc);
-        Assert.assertEquals(0, out.getLength());
-        Assert.assertEquals(length, resHeaders.get("Content-Length").get(0));
     }
 }


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


[tomcat] 01/03: Revert "Fix failing test. There should be no C-L for HEAD unless Servlet sets it"

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 97d6ef12c09e52e43c2ddf0bb7cf9e6fc32b84b2
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu May 25 14:00:57 2023 +0100

    Revert "Fix failing test. There should be no C-L for HEAD unless Servlet sets it"
    
    This reverts commit 7828614e36069ef1d08ad7eab36b4708bfaae9a2.
    The change that necessitated this change is also being reverted.
---
 test/org/apache/catalina/servlets/TestDefaultServlet.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/test/org/apache/catalina/servlets/TestDefaultServlet.java b/test/org/apache/catalina/servlets/TestDefaultServlet.java
index dca67ff9cb..b67cc325d4 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServlet.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServlet.java
@@ -636,11 +636,10 @@ public class TestDefaultServlet extends TomcatBaseTest {
         String length = resHeaders.get("Content-Length").get(0);
         Assert.assertEquals(Long.parseLong(length), out.getLength());
         out.recycle();
-        resHeaders.clear();
 
         rc = headUrl(path, out, resHeaders);
         Assert.assertEquals(HttpServletResponse.SC_OK, rc);
         Assert.assertEquals(0, out.getLength());
-        Assert.assertNull(resHeaders.get("Content-Length"));
+        Assert.assertEquals(length, resHeaders.get("Content-Length").get(0));
     }
 }


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