users@jersey.java.net

Re: [Jersey] Response of a DELETE method ?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 02 Nov 2009 11:30:37 +0100

On Nov 1, 2009, at 3:05 PM, Felipe Gaścho wrote:

> arena.path("competition").path(competitionName).delete();
>
> How to get a Response from this line ? it is void..
>

You should be receiving a 204 status code. We have unit tests in
place to verify this and i also did a quick test with a simple Web
application.

Do you have any server-side filters that might affect the response?

Are you throwing an exception from the method that results in being
mapped to a 200 response?


> if I do it with curl, I got:
>
> fgaucho_at_Fortunario:~/mercurial/puj~arena$ curl -i -XDELETE
> http://fgaucho.dyndns.org:8080/arena-http/competition/PUJCE-09
> HTTP/1.1 200 OK
> X-Powered-By: Servlet/3.0
> Server: GlassFish v3
> Content-Length: 0
> Date: Sun, 01 Nov 2009 14:02:00 GMT
>

I did a curl with DELETE on the above and received a 200 response then
i did a GET and received a 204 response.


> so, how do I get the same HTTP 200 from the Jersey Client ?
>


Do:

   ClientResponse cr =
arena
.path("competition").path(competitionName).delete(ClientResponse.class);

Paul.