Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-217

JAX-RS Content Negotiation does not follow RFC 2616 section 14.1

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.2.GA
    • 1.0.2.GA
    • None
    • None

      Service definition goes like this:
      @GET
      @Path(GET_PATH)
      @Produces(

      { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML+"; q=0.5" }

      )
      @Mapped(attributesAsElements=

      {"id"}

      )
      PlaceDto findById(@PathParam("id") Long id,
      @HeaderParam(PlacesRestUtil.COUNTRY_HEADER) String country,
      @HeaderParam(PlacesRestUtil.USER_HEADER) String ncimId);

      When executing request with Accept header:
      text/html,application/xhtml+xml,application/xml,/;q=0.8
      output is XML

      and when with:
      text/html,application/xhtml+xml,/;q=0.8,application/xml
      output is JSON

      Content type should be provided based on "relative degree of preference - q" not on position of the media type in Accept header string.
      Most important is that according to RE documentation:

      "Accept header or @Produces @Consumes can also specify weighted preferences that are used to match up requests with resource methods. This is best explained by RFC 2616 section 14.1"

      ... service specified as above should return JSON in both cases.

              patriot1burke@gmail.com Bill Burke (Inactive)
              marek.krysiuk_jira Marek Krysiuk (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: