dev@jsr311.java.net

Re: Content Negotiation

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 18 Sep 2007 11:09:11 +0200

Ryan McDonough wrote:
> I was just scanning the mailing list archive to see what decisions
> have been made in regards to Content Negotiation such as Language,
> Encoding, Charset, and potentially assigning a server-side quality
> value for a given mime type. I know I got involved in this list a bit
> later than most, but I'm curious to know if any decisions have been
> made or if this area is still open for debate?
>

I think it is still open.

Assigning a quality parameter for a Produce/ConsumeMime would enable the
deterministic selecting of the appropriate HTTP method. Currently for
Jersey it is based on method the order of methods returned by Java
reflection, the order of which is arbitrary. So for the following:

    @HttpMethod
    @ProduceMime("application/xml") byte[] getXml() { ... }

    @HttpMethod
    @ProduceMime("application/json") byte[] getJson() { ... }

The media type "application/xml" takes precedence on the Sun JVM. If we
could do:

    @HttpMethod
    @ProduceMime("application/xml") byte[] getXml() { ... }

    @HttpMethod
    @ProduceMime("application/json;q=0.9") byte[] getJson() { ... }

Then it means the media type "application/xml" always takes precedence
over "application/json" regardless of the method order. Perhaps we
should also specify precedence rules for inheritance of HTTP methods
that produce media with the same quality? Or another, easier, way is to
allow q values > 1



As for general content negotiation on media, language, encoding and
charset there many discussions about returning the set of meta-data of
the resource to the runtime to do processing, but we did not manage to
come to agreement on how this would work. I was leaning towards a
general acceptability processor that would work in a similar fashion to
the precondition evaluator.

Either way we go i think we need to come up with clear and consistent
examples that cover the common set of HTTP methods and usage (for
example, using GET and PUT with preconditions) with static/dynamic
declaration of the meta-data.

Paul.

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