Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion java/org/apache/coyote/http2/Stream.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ public final void emitHeader(String name, String value) throws HpackException {
}

if ("te".equals(name)) {
if (!"trailers".equals(value)) {
// "trailers" is an ABNF literal so it is case-insensitive (RFC 9110, section 10.1.4 and RFC 5234)
if (!"trailers".equalsIgnoreCase(value)) {
headerException =
new StreamException(sm.getString("stream.header.te", getConnectionId(), getIdAsString(), value),
Http2Error.PROTOCOL_ERROR, getIdAsInt());
Expand Down
52 changes: 52 additions & 0 deletions test/org/apache/coyote/http2/TestHttp2Section_8_1.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,58 @@ public void testPseudoHeaderOrder() throws Exception {
}


@Test
public void testTeTrailers() throws Exception {
doTestTe("trailers", true);
}


@Test
public void testTeTrailersMixedCase() throws Exception {
doTestTe("Trailers", true);
}


@Test
public void testTeTrailersUpperCase() throws Exception {
doTestTe("TRAILERS", true);
}


@Test
public void testTeInvalid() throws Exception {
doTestTe("gzip", false);
}


private void doTestTe(String value, boolean valid) throws Exception {
http2Connect();

List<Header> headers = new ArrayList<>(5);
headers.add(new Header(":method", Method.GET));
headers.add(new Header(":scheme", "http"));
headers.add(new Header(":path", "/simple"));
headers.add(new Header(":authority", "localhost:" + getPort()));
headers.add(new Header("te", value));

byte[] headersFrameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);

buildGetRequest(headersFrameHeader, headersPayload, null, headers, 3);

writeFrame(headersFrameHeader, headersPayload);

parser.readFrame();

String trace = output.getTrace();
if (valid) {
Assert.assertTrue(trace, trace.contains("3-Header-[:status]-[200]"));
} else {
Assert.assertEquals("3-RST-[1]\n", trace);
}
}


@Test
public void testHostHeaderValid() throws Exception {
http2Connect();
Expand Down
6 changes: 6 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,12 @@
<code>destroy()</code> is only called if <code>init()</code> was called
for the handler. (markt)
</fix>
<fix>
Compare the value of the HTTP/2 <code>te</code> request header to
<code>trailers</code> case-insensitively, rather than resetting the
stream when the value is not in lower case. Pull request <pr>1273</pr>
provided by Arturo Bernal.
</fix>
</changelog>
</subsection>
<subsection name="Jasper">
Expand Down