DispatcherServlet and ServletWrapping/ForwardingController accept any HTTP method by default
Issue: SPR-4799
This commit is contained in:
parent
08748ecaa4
commit
3d87718fc6
|
@ -61,7 +61,7 @@ public enum HttpMethod {
|
|||
* @since 4.2.4
|
||||
*/
|
||||
public boolean matches(String method) {
|
||||
return name().equals(method);
|
||||
return (this == resolve(method));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -838,7 +838,8 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
|||
protected void service(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
if (HttpMethod.PATCH.matches(request.getMethod())) {
|
||||
HttpMethod httpMethod = HttpMethod.resolve(request.getMethod());
|
||||
if (HttpMethod.PATCH == httpMethod || httpMethod == null) {
|
||||
processRequest(request, response);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -94,6 +94,26 @@ public abstract class AbstractController extends WebContentGenerator implements
|
|||
private boolean synchronizeOnSession = false;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new AbstractController which supports
|
||||
* HTTP methods GET, HEAD and POST by default.
|
||||
*/
|
||||
public AbstractController() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AbstractController.
|
||||
* @param restrictDefaultSupportedMethods {@code true} if this
|
||||
* controller should support HTTP methods GET, HEAD and POST by default,
|
||||
* or {@code false} if it should be unrestricted
|
||||
* @since 4.3
|
||||
*/
|
||||
public AbstractController(boolean restrictDefaultSupportedMethods) {
|
||||
super(restrictDefaultSupportedMethods);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set if controller execution should be synchronized on the session,
|
||||
* to serialize parallel invocations from the same client.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -90,6 +90,11 @@ public class ServletForwardingController extends AbstractController implements B
|
|||
private String beanName;
|
||||
|
||||
|
||||
public ServletForwardingController() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the name of the servlet to forward to,
|
||||
* i.e. the "servlet-name" of the target servlet in web.xml.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -95,6 +95,11 @@ public class ServletWrappingController extends AbstractController
|
|||
private Servlet servletInstance;
|
||||
|
||||
|
||||
public ServletWrappingController() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the class of the servlet to wrap.
|
||||
* Needs to implement {@code javax.servlet.Servlet}.
|
||||
|
|
Loading…
Reference in New Issue