jersey
  1. jersey
  2. JERSEY-1461

Response does not contain ContentType from @Produces on a resource class

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Invalid
    • Affects Version/s: 2.0-m08
    • Fix Version/s: 2.0-m10, 2.0
    • Component/s: core
    • Labels:
      None

      Description

      @Produces(MediaType.TEXT_HTML)
      @Path("resource")
      public class MediaResource {
      	@GET
      	@Path("class")
      	public Response clazz(){
      		return Response.ok().build();
      	}
      }
      

      Request / Response to this resource is:

      >> "GET /web/resource/class HTTP/1.1[\r][\n]"
      >> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
      >> "Host: localhost:6080[\r][\n]"
      >> "[\r][\n]"
      << "HTTP/1.1 200 OK[\r][\n]"
      << "Server: Apache-Coyote/1.1[\r][\n]"
      << "Content-Length: 0[\r][\n]"
      << "Date: Wed, 10 Oct 2012 14:21:26 GMT[\r][\n]"
      << "[\r][\n]"

      Spec., Chapter 3.8, Step 2. says:

      Else if the class is annotated with @Produces, set P = V (class).

        Activity

        Hide
        jan.supol added a comment -

        See Jersey-1463 for the possible reason

        Show
        jan.supol added a comment - See Jersey-1463 for the possible reason
        Hide
        Pavel Bucek added a comment -

        well.. if there is no entity, there is no content-type; can you re-test with actually returning some entity?

        Show
        Pavel Bucek added a comment - well.. if there is no entity, there is no content-type; can you re-test with actually returning some entity?
        Hide
        jan.supol added a comment - - edited

        Rfc 2616, section 14.17 says:

        The Content-Type entity-header field indicates the media type of the entity-body sent to the recipient or, in the case of the HEAD method, the media type that would have been sent had the request been a GET.

        This does neither say the Content-Type can be omitted when no entity, nor it says it should not be omitted, correct, but it surely say it shall be there for HEAD requests, which Jersey have not.

        Show
        jan.supol added a comment - - edited Rfc 2616, section 14.17 says: The Content-Type entity-header field indicates the media type of the entity-body sent to the recipient or, in the case of the HEAD method, the media type that would have been sent had the request been a GET. This does neither say the Content-Type can be omitted when no entity, nor it says it should not be omitted, correct, but it surely say it shall be there for HEAD requests, which Jersey have not.
        Hide
        Pavel Bucek added a comment -

        I haven't seen any HEAD request in issue description..

        anyway, HEAD is about receiving everything exact response as GET would return, but with not entity (all headers should be preserved, even Content-Length and Content-Type).

        Show
        Pavel Bucek added a comment - I haven't seen any HEAD request in issue description.. anyway, HEAD is about receiving everything exact response as GET would return, but with not entity (all headers should be preserved, even Content-Length and Content-Type).
        Hide
        Pavel Bucek added a comment -

        I would propose to close this one and continue in JERSEY-1463, is it ok? (seems like duplicate to me and the other one is more relevant to the real cause).

        Show
        Pavel Bucek added a comment - I would propose to close this one and continue in JERSEY-1463 , is it ok? (seems like duplicate to me and the other one is more relevant to the real cause).
        Hide
        jan.supol added a comment -

        I see. Please close both 1461 and 1463 as invalid, then.

        Show
        jan.supol added a comment - I see. Please close both 1461 and 1463 as invalid, then.

          People

          • Assignee:
            Pavel Bucek
            Reporter:
            jan.supol
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 3 hours
              3h
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 1 hour Time Not Required
              1h