Skip to content

Commit

Permalink
Restore DefaultServlet.doPost to the previous major releases' behavior (
Browse files Browse the repository at this point in the history
#11300)

#11299 restore DefaultServlet.doPost to the previous major releases' behavior

Signed-off-by: Ludovic Orban <[email protected]>
  • Loading branch information
lorban authored Jan 24, 2024
1 parent ce928e5 commit 7fbd51a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
doGet(request, response);
}

@Override
Expand All @@ -535,7 +535,7 @@ protected void doTrace(HttpServletRequest request, HttpServletResponse response)
protected void doOptions(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setHeader("Allow", "GET, HEAD, OPTIONS");
response.setHeader("Allow", "GET,HEAD,POST,OPTIONS");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2229,7 +2229,7 @@ public void testPost() throws Exception
abcde
""");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.METHOD_NOT_ALLOWED_405));
assertThat(response.toString(), response.getStatus(), is(HttpStatus.NOT_FOUND_404));

Files.writeString(file, "How now brown cow", UTF_8);

Expand All @@ -2242,7 +2242,8 @@ public void testPost() throws Exception
abcde
""");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.METHOD_NOT_ALLOWED_405));
assertThat(response.toString(), response.getStatus(), is(HttpStatus.OK_200));
assertThat(response.getContent(), is("How now brown cow"));
}

@Test
Expand Down Expand Up @@ -2279,7 +2280,7 @@ public void testOptions() throws Exception
""");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.OK_200));
assertThat(response.get(HttpHeader.ALLOW), is("GET, HEAD, OPTIONS"));
assertThat(response.get(HttpHeader.ALLOW), is("GET,HEAD,POST,OPTIONS"));
}

@Test
Expand Down

0 comments on commit 7fbd51a

Please sign in to comment.