Skip to content

Commit 914dcca

Browse files
committed
Merge branch '2.2.x' into 2.3.x
Closes gh-23555
2 parents 74a164e + 323af71 commit 914dcca

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyEmbeddedErrorHandler.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,9 @@
1717
package org.springframework.boot.web.embedded.jetty;
1818

1919
import java.io.IOException;
20+
import java.util.Arrays;
21+
import java.util.HashSet;
22+
import java.util.Set;
2023

2124
import javax.servlet.http.HttpServletRequest;
2225
import javax.servlet.http.HttpServletResponse;
@@ -37,6 +40,8 @@
3740
*/
3841
class JettyEmbeddedErrorHandler extends ErrorPageErrorHandler {
3942

43+
private static final Set<String> HANDLED_HTTP_METHODS = new HashSet<>(Arrays.asList("GET", "POST", "HEAD"));
44+
4045
@Override
4146
public boolean errorPageForMethod(String method) {
4247
return true;
@@ -45,7 +50,9 @@ public boolean errorPageForMethod(String method) {
4550
@Override
4651
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
4752
throws IOException {
48-
baseRequest.setMethod("GET");
53+
if (!HANDLED_HTTP_METHODS.contains(baseRequest.getMethod())) {
54+
baseRequest.setMethod("GET");
55+
}
4956
super.doError(target, baseRequest, request, response);
5057
}
5158

0 commit comments

Comments
 (0)