public final class HiddenHttpMethod extends java.lang.Object
Resolves the hidden HTTP method override a browser form requests through a _method parameter.
Browsers submit only GET and POST, so a form that needs to reach a PUT,
PATCH or DELETE route names the method in a request parameter instead. This is the same
convention org.grails.web.filters.HiddenHttpMethodFilter implements, applied inside the dispatcher
rather than ahead of it — deliberately narrower than the filter, which accepts any method name and also
trusts an X-HTTP-Method-Override header.
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
DEFAULT_METHOD_PARAM |
Default method parameter: _method |
static java.lang.String |
OVERRIDDEN_METHOD_ATTRIBUTE |
Request attribute carrying the method a request asked to be treated as, published by the dispatcher when it resolves an override. |
static java.lang.String |
SPRING_FILTER_ENABLED |
Spring Boot's equivalent of Settings.WEB_HIDDEN_METHOD_FILTER_ENABLED, also false by default. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static java.lang.String |
effectiveMethod(HttpServletRequest request)The method this request is being handled as: the override the dispatcher resolved, when there was one, and otherwise the request's own method. |
|
public static boolean |
isServletFilterMode(PropertyResolver properties)Whether a servlet filter rewrites the request method, rather than it being resolved inside the dispatcher. |
|
public static java.lang.String |
resolveOverride(HttpServletRequest request)The method this request asks to be treated as, or null when it asks for nothing: it is not a
POST, carries no _method parameter, or names a method that may not be requested this way. |
|
public static HttpServletRequest |
wrap(java.lang.String method, HttpServletRequest request)Wraps a request so that HttpServletRequest.getMethod reports the overriding method, leaving everything else delegating to the wrapped request. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
Default method parameter: _method
Request attribute carrying the method a request asked to be treated as, published by the dispatcher when it resolves an override.
Spring Boot's equivalent of Settings.WEB_HIDDEN_METHOD_FILTER_ENABLED, also false by default.
The method this request is being handled as: the override the dispatcher resolved, when there was one, and otherwise the request's own method.
Use this wherever a decision depends on the method the handler was selected for -- allowedMethods, for instance -- rather than on the method the client actually sent. A servlet filter
doing the override rewrites HttpServletRequest.getMethod and this returns the same answer,
so it is correct in either mode.
request - the current requestnullWhether a servlet filter rewrites the request method, rather than it being resolved inside the dispatcher. True when either this application or Spring Boot has asked for a filter.
Whenever this returns true a filter really is on the chain, so callers need not check the context for
one - see GrailsHiddenHttpMethodFilterAutoConfiguration, which holds that invariant up.
properties - the environment or configuration to read The method this request asks to be treated as, or null when it asks for nothing: it is not a
POST, carries no _method parameter, or names a method that may not be requested this way.
request - the current requestnullWraps a request so that HttpServletRequest.getMethod reports the overriding method, leaving everything else delegating to the wrapped request.
method - the overriding method namerequest - the request to wrap