Skip to main content
Last updated September 06, 2011 18:33, by m_potociar

Server side content negotiation

The purpose of the proposed feature is to allow resource designers to specify their preference of the served (response) content. This preference is a secondary preference to the client-side preference specified in the HTTP Accept request header.

It is proposed that, in accordance with the JAX-RS 1.1 section 3.5 Declaring Media Type Capabilities, server-side preference is specified as part of the @Produces annotation value on either (in this order of preference):

  1. resource method
  2. resource class
  3. entity provider

Server side preference must be specified as a qs-value of the declared media type:

public class Resource {
    @Produces("text/html", "application/xml;qs=0.7")
    public String getResource() { ... }
Determining the default server-side qs-value as well as the final order of server-side served types preference must follow the same rules as those specified for HTTP Accept header.

Changes to the specification text

In reference to the JAX-RS 1.1 specification, following changes in the specification text should be made:

  • Section 3.5 should discuss the ability to specify server-side qs-value.
  • Section 3.8 should be updated as follows:
    • the if-clause in step 5 should read: If a is compatible with p, add S(a, p) to M , where the function S returns the most specific media type of the pair with the q-value of a and server-side qs-value of p.
    • step 7 should read: Sort M in descending order, with a primary key of specificity (n/m > n/* > */*), and secondary key of q-value and tertiary key of server-side qs-value.

Related material


Please Confirm