|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.jersey.api.container.filter.PostReplaceFilter
public class PostReplaceFilter
A filter to support HTTP method replacing of a POST request to a request utilizing another HTTP method for the case where proxies or HTTP servers would otherwise block that HTTP method.
This filter may be used to replace a POST request with a PUT, DELETE or GET request.
Replacement will occur if the request method is POST and there exists either
a request header "X-HTTP-Method-Override", or
a query parameter "_method" with a non-empty value. That value
will be the HTTP method that replaces the POST method. In addition to that,
when replacing the POST method with GET, the filter will convert the form parameters
to query parameters. If the filter is configured to look for both the X-HTTP-Method-Override
header as well as the _method query parameter (the default setting), both are present in the
request and they differ, the filter returns Response.Status.BAD_REQUEST
response.
When an application is deployed as a Servlet or Filter this Jersey filter can be registered using the following initialization parameter:
<init-param> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name> <param-value>com.sun.jersey.api.container.filter.PostReplaceFilter</param-value> </init-param>
The filter can be configured using the com.sun.jersey.api.container.filter.PostReplaceFilterConfig property.
See PROPERTY_POST_REPLACE_FILTER_CONFIG
for the supported property values.
com.sun.jersey.api.container.filter
Nested Class Summary | |
---|---|
static class |
PostReplaceFilter.ConfigFlag
Enum representing configuration flags that can be set on the filter. |
Field Summary | |
---|---|
static java.lang.String |
PROPERTY_POST_REPLACE_FILTER_CONFIG
Property that may contain a comma-separated list of the configuration flags to be set on this filter. |
Constructor Summary | |
---|---|
PostReplaceFilter(PostReplaceFilter.ConfigFlag... configFlags)
Initializes this filter with config flags. |
|
PostReplaceFilter(ResourceConfig rc)
Initializes this filter with PROPERTY_POST_REPLACE_FILTER_CONFIG property value from the application resource config. |
Method Summary | |
---|---|
ContainerRequest |
filter(ContainerRequest request)
Filter the request. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PROPERTY_POST_REPLACE_FILTER_CONFIG
PostReplaceFilter.ConfigFlag
enum lists the allowed config flags.
If this property is not set, the default value "HEADER,QUERY" will be used to initialize the filter.
When an application is deployed as a servlet or filter this property can be set using the following initialization parameter:
The above setting would cause the filter would only look at the X-HTTP-Method-Override header and ignore _method query parameter.<init-param> <param-name>com.sun.jersey.api.container.filter.PostReplaceFilterConfig</param-name> <param-value>HEADER</param-value> </init-param>
Constructor Detail |
---|
public PostReplaceFilter(@Context ResourceConfig rc)
PROPERTY_POST_REPLACE_FILTER_CONFIG
property value from the application resource config.
If the property has no value, both PostReplaceFilter.ConfigFlag.HEADER
and PostReplaceFilter.ConfigFlag.QUERY
will be added to the config.
rc
- resource config (injected by Jersey)public PostReplaceFilter(PostReplaceFilter.ConfigFlag... configFlags)
configFlags
- Config flags to initialize the filter with. If no config flags are passed,
both PostReplaceFilter.ConfigFlag.HEADER
and PostReplaceFilter.ConfigFlag.QUERY
will be added to the config.Method Detail |
---|
public ContainerRequest filter(ContainerRequest request)
ContainerRequestFilter
An implementation may modify the state of the request or create a new instance.
filter
in interface ContainerRequestFilter
request
- the request.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |