Merge branch '2.3.x'

Closes gh-23557
pull/23559/head
Andy Wilkinson 4 years ago
commit 65c7cd43db

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,6 +17,9 @@
package org.springframework.boot.web.embedded.jetty; package org.springframework.boot.web.embedded.jetty;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -37,6 +40,8 @@ import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
*/ */
class JettyEmbeddedErrorHandler extends ErrorPageErrorHandler { class JettyEmbeddedErrorHandler extends ErrorPageErrorHandler {
private static final Set<String> HANDLED_HTTP_METHODS = new HashSet<>(Arrays.asList("GET", "POST", "HEAD"));
@Override @Override
public boolean errorPageForMethod(String method) { public boolean errorPageForMethod(String method) {
return true; return true;
@ -45,7 +50,9 @@ class JettyEmbeddedErrorHandler extends ErrorPageErrorHandler {
@Override @Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException { throws IOException {
baseRequest.setMethod("GET"); if (!HANDLED_HTTP_METHODS.contains(baseRequest.getMethod())) {
baseRequest.setMethod("GET");
}
super.doError(target, baseRequest, request, response); super.doError(target, baseRequest, request, response);
} }

Loading…
Cancel
Save