On Apr 13, 2010, at 10:16 PM, Laird Nelson wrote:
> On Tue, Apr 13, 2010 at 4:09 PM, Laird Nelson <ljnelson_at_gmail.com>
> wrote:
>> I'm curious about taking in a form submission from a browser that is
>> *logically* supposed to be a PUT operation but that comes in as a
>> POST.
>
> I see from https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/container/filter/PostReplaceFilter.html
> that this must be what Paul was talking about. However, it still has
> a TODO section that implies that the query string parameter support
> here is not yet done. Is that accurate?
>
Right. I was pausing to decide whether implementing query parameter
support this for this is a good idea or not. Namely, is one way better
than many? Also there seems to be a well-defined convention for the
HTTP header but i could not find such a convention for query or form
parameters, any suggestions?
Can you utilize the X-HTTP-Method-Override method in your app?
Note that if you need this in your app now it should be easy to copy
the code and modify it, example shown below. A similar approach can be
achieved for form parameters as well.
Paul.
public class QueryParamPostReplaceFilter implements
ContainerRequestFilter {
public ContainerRequest filter(ContainerRequest request) {
if (!request.getMethod().equalsIgnoreCase("POST"))
return request;
MultivaluedMap<String, String> qps =
request.getQueryParameters();
String override = qps.getFirst("_method_override");
if (override == null)
return request;
override = override.trim();
if (override.length() == 0)
return request;
request.setMethod(override);
return request;
}
}