users@jersey.java.net

Re: [Jersey] Does JAX-RS support X-HTTP-Method-Override?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 07 Oct 2008 17:31:22 +0200

On Oct 7, 2008, at 5:21 PM, Gili wrote:

>
> See the first answer at
> http://stackoverflow.com/questions/153420/is-it-feasible-to-create-a-rest-client-with-flex
>
> Ideally I'd want it to handle this header seamlessly so @DELETE gets
> called
> even if the client actually sent a POST with X-HTTP-Method-
> Override="DELETE"
>

Yes, but it is not enabled by default. You can enable it by adding the
following to the web.xml:

<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>

See JavaDoc of:

  com.sun.jersey.spi.container.ContainerRequestFilter
  com.sun.jersey.spi.container.ContainerResponseFilter
  ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS
  ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS

for more details.


> On a related note, don't we lose most of the power of REST when
> doing this?
> :) I mean, we're tunneling through HTTP again. Proxies lose the
> ability to
> cache, etc.
>

I don't think you loose a lot in terms of caching. Essentially proxies
observe a contraction of the uniform interface. The RESTful style is
still there, URIs, hyper-media, request-response, statelessness etc.
It is one of those annoying pragmatic solutions to get around, what
appears to be, an arbitrary technical limitation.

Paul.