Process T-E header from both HTTP 1.0 and HTTP 1.1. clients · apache/tomcat@05f9e8b · GitHub
Skip to content

Commit

Permalink
Process T-E header from both HTTP 1.0 and HTTP 1.1. clients
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Jun 8, 2021
1 parent 45d70a8 commit 05f9e8b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion java/org/apache/coyote/http11/Http11Processor.java
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,9 @@ private void prepareRequest() throws IOException {
InputFilter[] inputFilters = inputBuffer.getFilters();

// Parse transfer-encoding header
if (http11) {
// HTTP specs say an HTTP 1.1 server should accept any recognised
// HTTP 1.x header from a 1.x client unless the specs says otherwise.
if (!http09) {
MessageBytes transferEncodingValueMB = headers.getValue("transfer-encoding");
if (transferEncodingValueMB != null) {
List<String> encodingNames = new ArrayList<>();
Expand Down
28 changes: 28 additions & 0 deletions test/org/apache/coyote/http11/TestHttp11Processor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1904,4 +1904,32 @@ private void doTestTEHeaderUnknown(String headerValue) throws Exception {

Assert.assertTrue(client.isResponse501());
}


@Test
public void testWithTEChunkedHttp10() throws Exception {

getTomcatInstanceTestWebapp(false, true);

String request =
"POST /test/echo-params.jsp HTTP/1.0" + SimpleHttpClient.CRLF +
"Host: any" + SimpleHttpClient.CRLF +
"Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
"Content-Type: application/x-www-form-urlencoded" +
SimpleHttpClient.CRLF +
"Connection: close" + SimpleHttpClient.CRLF +
SimpleHttpClient.CRLF +
"9" + SimpleHttpClient.CRLF +
"test=data" + SimpleHttpClient.CRLF +
"0" + SimpleHttpClient.CRLF +
SimpleHttpClient.CRLF;

Client client = new Client(getPort());
client.setRequest(new String[] {request});

client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse200());
Assert.assertTrue(client.getResponseBody().contains("test - data"));
}
}
4 changes: 4 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@
in 2001. Requests using this transfer encoding will now receive a 501
response. (markt)
</fix>
<fix>
Process transfer encoding headers from both HTTP 1.0 and HTTP 1.1
clients. (markt)
</fix>
</changelog>
</subsection>
<subsection name="Jasper">
Expand Down

0 comments on commit 05f9e8b

Please sign in to comment.