This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit cc7006946414f4dc08c704ff5bca391f7641532c Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri May 3 15:54:15 2024 +0100 Fix off-by-error causing first response header to be dropped. Fix based on #710 by foremans. --- java/org/apache/coyote/http11/Http11Processor.java | 3 ++- test/org/apache/coyote/http11/TestHttp11OutputBuffer.java | 1 + webapps/docs/changelog.xml | 9 +++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index dc5d96c870..681db0e96b 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -1052,7 +1052,8 @@ public class Http11Processor extends AbstractProcessor { size--; // Header buffer is corrupted. Reset it and start again. outputBuffer.resetHeaderBuffer(); - i = 0; + // -1 as it will be incremented at the start of the loop and header indexes start at 0. + i = -1; outputBuffer.sendStatus(); } } diff --git a/test/org/apache/coyote/http11/TestHttp11OutputBuffer.java b/test/org/apache/coyote/http11/TestHttp11OutputBuffer.java index 00a4664d75..4f63cb13f6 100644 --- a/test/org/apache/coyote/http11/TestHttp11OutputBuffer.java +++ b/test/org/apache/coyote/http11/TestHttp11OutputBuffer.java @@ -110,6 +110,7 @@ public class TestHttp11OutputBuffer extends TomcatBaseTest { Assert.assertEquals(HttpServletResponse.SC_OK, rc); List<String> values = resHeaders.get(HeaderServlet.CUSTOM_HEADER_NAME); Assert.assertNull(values); + Assert.assertEquals(5, resHeaders.size()); } } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index e764aed747..8c3f7d5625 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -155,7 +155,7 @@ </fix> <fix> Remove MBean metadata for attibutes that have been removed. Based on - <pr>719</pr> by Shawn Q. (markt) + pull request <pr>719</pr> by Shawn Q. (markt) </fix> <scode> Remove duplicate ID check from <code>Manager.rotateSessionId()</code>. @@ -206,6 +206,11 @@ <scode> Refactor HTTP header parsing to use common parsing code. (markt) </scode> + <fix> + When an invalid HTTP response header was dropped, an off-by-one error + meant that the first header in the response was also dropped. Fix based + on pull request <pr>710</pr> by foremans. (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> @@ -424,7 +429,7 @@ <changelog> <fix> Minor performance improvement for building filter chains. Based on - ideas from <pr>702</pr> by Luke Miao. (remm) + ideas from pull request <pr>702</pr> by Luke Miao. (remm) </fix> <fix> Align error handling for <code>Writer</code> and --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org