Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5129

Content type is always "text/xml" in case of using @Context HttpServletResponse response

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7.5
    • 2.7.6, 3.0.0-milestone1
    • None
    • None
    • Unknown

    Description

      In case of next endpoint with @Context HttpServletResponse:

      @GET
      @Path("test")
      @Produces(MediaType.TEXT_PLAIN)
      public void test(@Context HttpServletResponse response) throws IOException {
             response.setContentType(MediaType.TEXT_PLAIN);
             response.getOutputStream().print("test");
      } 
      

      Content-Type in received message is always "text/xml":

      [bash]$ curl "http://localhost:8030/test" -D -
      HTTP/1.1 200 OK
      Content-Type: text/xml;charset=UTF-8
      Content-Length: 4
      

      So it is impossible to change Content-Type when @Context is used.
      response.setContentType(MediaType.TEXT_PLAIN) doesn't work as well as @Produces(MediaType.TEXT_PLAIN)

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            smalafeev Sergei Malafeev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: