users@jsr311.java.net

SC_OK or SC_NO_CONTENT

From: Bill Burke <bburke_at_redhat.com>
Date: Mon, 19 May 2008 08:24:34 -0400

JSR 311 users, see question inlined from our user base.

JXrgen Zimmermann wrote:
> Inside a Resource's method annotated with @DELETE I'm producing the
> response this way:
> return Response.ok().build();
>
> Resteasy returns to the client: SC_OK (= 200)
> Jersey returns to the client: SC_NO_CONTENT (= 204)
>


HTTP Spec says:

"A successful response SHOULD be 200 (OK) if the response includes an
entity describing the status, 202 (Accepted) if the action has not yet
been enacted, or 204 (No Content) if the action has been enacted but the
response does not include an entity."

IMO, you should be able to return anything you want as the spec says
"SHOULD" and not "MUST". Since you are building the response, IMO,
Jersey is in error. If you were not building the Response object
yourself, then it should be 204 if there is a void return type, 200 if
there is a non-void. I'll ping the expert group.

I'll ask the spec (in copy).

Bill


-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com