Skip to content

Commit

Permalink
Fix off-by-error causing first response header to be dropped.
Browse files Browse the repository at this point in the history
Fix based on #710 by foremans.
  • Loading branch information
markt-asf committed May 3, 2024
1 parent 4fd9f16 commit 404b8b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion java/org/apache/coyote/http11/Http11Processor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
1 change: 1 addition & 0 deletions test/org/apache/coyote/http11/TestHttp11OutputBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private void doTestHTTPHeaderValue(String customHeaderValue, boolean valid) thro
Assert.assertEquals(HttpServletResponse.SC_OK, rc);
List<String> values = resHeaders.get(HeaderServlet.CUSTOM_HEADER_NAME);
Assert.assertNull(values);
Assert.assertEquals(5, resHeaders.size());
}
}

Expand Down
7 changes: 6 additions & 1 deletion webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 404b8b0

Please sign in to comment.