This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 404b8b06de Fix off-by-error causing first response header to be
dropped.
404b8b06de is described below
commit 404b8b06dea84dd8a0e989d7076df01b4f904562
Author: Mark Thomas <[email protected]>
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 | 7 ++++++-
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/coyote/http11/Http11Processor.java
b/java/org/apache/coyote/http11/Http11Processor.java
index 8bc508cbb4..6e88c9c438 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -1053,7 +1053,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 feae71c740..82752abf38 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 434b72cfeb..2538276305 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -184,6 +184,11 @@
<fix>
Fix non-blocking reads of chunked request bodies. (markt)
</fix>
+ <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">
@@ -360,7 +365,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: [email protected]
For additional commands, e-mail: [email protected]