diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index 8bc508cbb4af..6e88c9c438c7 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -1053,7 +1053,8 @@ protected final void prepareResponse() throws IOException { 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 feae71c74038..82752abf387f 100644 --- a/test/org/apache/coyote/http11/TestHttp11OutputBuffer.java +++ b/test/org/apache/coyote/http11/TestHttp11OutputBuffer.java @@ -110,6 +110,7 @@ private void doTestHTTPHeaderValue(String customHeaderValue, boolean valid) thro Assert.assertEquals(HttpServletResponse.SC_OK, rc); List 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 434b72cfebbf..253827630593 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -184,6 +184,11 @@ Fix non-blocking reads of chunked request bodies. (markt) + + 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 710 by foremans. (markt) + @@ -360,7 +365,7 @@ Minor performance improvement for building filter chains. Based on - ideas from 702 by Luke Miao. (remm) + ideas from pull request 702 by Luke Miao. (remm) Align error handling for Writer and