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 792b496 commit cc70069
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 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 @@ -1052,7 +1052,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
9 changes: 7 additions & 2 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>.
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cc70069

Please sign in to comment.