Skip to content

Commit

Permalink
Added test for invalid Content-Length header with rejectIllegalHeader…
Browse files Browse the repository at this point in the history
… config
  • Loading branch information
cesarhernandezgt committed Nov 11, 2022
1 parent 6b69621 commit 038f94a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/org/apache/coyote/http11/TestInternalInputBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,35 @@ public void testInvalidHeader01() {
Assert.assertTrue(client.isResponseBodyOK());
}

@Test
public void testInvalidContentLength01() {
doTestInvalidContentLength(false);
}


@Test
public void testInvalidContentLength02() {
doTestInvalidContentLength(true);
}


private void doTestInvalidContentLength(boolean rejectIllegalHeader) {
getTomcatInstance().getConnector().setProperty("rejectIllegalHeader", Boolean.toString(rejectIllegalHeader));

String[] request = new String[1];
request[0] =
"POST /test HTTP/1.1" + CRLF +
"Host: localhost:8080" + CRLF +
"Content-Length: 12\u000734" + CRLF +
"Connection: close" + CRLF +
CRLF;

InvalidClient client = new InvalidClient(request);

client.doRequest();
Assert.assertTrue(client.getResponseLine(), client.isResponse400());
Assert.assertTrue(client.isResponseBodyOK());
}

/**
* Invalid request test client.
Expand Down

0 comments on commit 038f94a

Please sign in to comment.