Craig,
Let me chime in again.
You can make this solution portable by simply writing your own HTTP Method Override Filter (Paraphrasing Arun Gupta’s recent advice: “if there is a standard solution, don’t use the proprietary alternative”). (NB this would be a perfect start for a library of portable JAX-RS extensions!).
An example how to do this is shown in this article of Adam Bien on the Oracle web site (
http://www.oracle.com/technetwork/articles/java/jaxrs20-1929352.html):
@Provider
@PreMatching
public class HttpMethodOverrideEnabler implements ContainerRequestFilter {
public void filter(ContainerRequestContext requestContext) throws IOException {
String override = requestContext.getHeaders().getFirst("X-HTTP-Method-Override");
if (override != null) {
requestContext.setMethod(override);
}
}
}
Regards
-Markus
Von: Craig McClanahan [mailto:craigmcc_at_gmail.com]
Gesendet: Donnerstag, 9. April 2015 21:50
An: users_at_jersey.java.net
Betreff: [Jersey] Re: Sending a PATCH request from JAX-RS client?
When I had a similar problem recently, I chose to have my server implement HttpMethodOverrideFilter (from Jersey) so that lame (non-PATCH-capable) clients could send an X-HTTP-Method-Override header and do a POST. Clients that do understand how to PATCH can still do it.
Craig
On Thu, Apr 9, 2015 at 10:13 AM, Simon Roberts <simon_at_dancingcloudphotography.com<mailto:simon_at_dancingcloudphotography.com>> wrote:
Thanks Markus,
That pushed my search a little further, and eventually I found that Jersey has a (seemingly undocumented?) feature for this:
client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
Seems to solve this adequately. Weird that it doens't appear to show up in the docs. Perhaps PATCH isn't all that common?
Cheers,
Simon
Subject: [Jersey] Re: Sending a PATCH request from JAX-RS client?
See
https://blogs.oracle.com/PavelBucek/entry/jersey_client_making_requests_with but AFAIK the name of the property was changed meanwhile.
Regards
-Markus