users@jersey.java.net

Re: [Jersey] Response status forced to 204 when body empty

From: Tatu Saloranta <cowtowncoder_at_yahoo.com>
Date: Thu, 8 May 2008 22:04:56 -0700 (PDT)

--- Bruno Luiz Pereira da Silva <blpsilva_at_gmail.com>
wrote:

> Hi guys, I have started using Jersey recently, but I
> have a reasonable
> experience with RESTFul web services.
>
> I have a doubt regarding the response status. I'm
> trying to return an HTTP
> 200 when the operation goes OK on the server, but
> when the response body is
> empty the status is always set to 204 (No Content).
>
> I tried using
> Response.status(Response.Status.OK).build(),
> Response..ok().status(Response.Status.OK).build()
> and several other
> variations of this, trying to force the status to
> 200.
>
> If I use Response.ok(object).build() the response
> status is set to 200.
> Can't I return 200 with an empty response body?

But isn't 204 (EMPTY_CONTENT) sort of "right" response
to give? It is a success code, after all (not a
failure), and indicates that there is no content to
return (as opposed to a failure to produce content or
so).
 
-+ Tatu +-



      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ