users@jsr311.java.net

Re: ResponseBuilder.type()

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

Stephan Koops wrote:
> Hi Paul,
>>> 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?
> Something like that is good. For 2xx we could forbid it.
> What should happen for status 1xx? The RFC
> (http://tools.ietf.org/html/rfc2616#section-10.1) says, that they
> include only the status line and perhaps headers. But I think here we
> should have no restrictions.

Good point, but i am not sure how 1xx plays in with responses from the
application. We need to look more closely at the implications of say 100
(Continue), which is currently lacking fundamental support in Servlet.


>> 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.
> You mean e.g. WADL generating tools?
>

Yes, or generated documentation by other means, like by hand, or just
looking at the source code. Plus when code changes it helps catch
regressions i.e. using @ProduceMime is a contract.

Paul.

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