users@jsr311.java.net

Re: ResponseBuilder.type()

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 20 Jun 2008 13:20:52 +0200

Stephan Koops wrote:
>> @ProduceMime({"application/bar", "application/foo"})
>> void Response get() {
>> return response.ok().
>> type(""application/baz").entity(someEntity).build();
>> }
>>
>> IMHO i think this should be an error because it contradicts the
>> declaration in @ProduceMime.
> IMO it should not be an error, because "HTTP/1.1 servers are allowed to
> return responses which are not acceptable according to the accept
> headers sent in the request." (from
> http://tools.ietf.org/html/rfc2616#section-10.4.7)
> I think: If the Response method sets a media type, the one of
> @ProduceMime must be ignored. An example for other media types could be,
> if the method want to send details for an error (or redirection with
> options) status.
>

Perhaps it should be based on the status code? If the status code is <
300 then it should be an error otherwise not?

I think it is important that @ProduceMime has value as a declaration for
those who are looking at the code and for generating documentation or
machine processable descriptions: namely under certain conditions the
media types declared in @ProduceMime are the only media types that may
be returned. This also makes it easier to stop errors creeping in if the
production of responses is somewhat separated from the resource method
itself.

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109