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

resteasy-html's View ignores Response headers and cookies

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.0.23.Final, 3.1.3.Final
    • 3.0.16.Final
    • None
    • None
    • Hide
      return Response.ok(new View("/some.jsp"))
          .cookie(new NewCookie("name", "value"))
          .build();
      

      The cookie won't be sent.

      Show
      return Response.ok( new View( "/some.jsp" )) .cookie( new NewCookie( "name" , "value" )) .build(); The cookie won't be sent.

      When using org.jboss.resteasy.plugins.providers.html.View from resteasy-html, headers and cookies set on the javax.ws.rs.Response are ignored.

      This is due to the View dispatching to a non-wrapped and unmodified javax.servlet.http.HttpServletResponse (injected as @Context) therefore writing directly to the getWriter(), before Resteasy processes the headers from the javax.ws.rs.Response (this is because a MessageBodyWriter is given the possibility to alter headers).

      The HtmlRenderableWriter should either arrange to write to the provided OutputStream (by wrapping the HttpServletResponse, or should process the incoming headers and apply/copy them to the HttpServletResponse (as is done in org.jboss.resteasy.core.ServerResponseWriter.commitHeaders).

      It might be possible to trigger this commitHeaders code simply by flush()-ing the provided OutputStream; and this might be doable in a WriterInterceptor as a workaround (I need to test that).

              rsigal@redhat.com Ronald Sigal
              t.broyer Thomas Broyer (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: