Restore DefaultServlet.doPost to the previous major releases' behavior (#11300)

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

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2024-01-24 21:53:30 +01:00 committed by GitHub
parent ce928e5ff1
commit 7fbd51a952
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -514,7 +514,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory, Welc
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
doGet(request, response);
}
@Override
@ -535,7 +535,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory, Welc
protected void doOptions(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setHeader("Allow", "GET, HEAD, OPTIONS");
response.setHeader("Allow", "GET,HEAD,POST,OPTIONS");
}
@Override

View File

@ -2229,7 +2229,7 @@ public class DefaultServletTest
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);
@ -2242,7 +2242,8 @@ public class DefaultServletTest
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
@ -2279,7 +2280,7 @@ public class DefaultServletTest
""");
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