Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-5845

[GSS](7.1.0) Resteasy does not set Expires attribute for NewCookie correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.1.0.DR8
    • 7.0.1.GA, 7.1.0.DR3
    • REST
    • None

      Backport RESTEASY-1476

      Resteasy does not set Expires attribute correctly when testing the following JAX-RS application using javax.ws.rs.core.NewCookie to set Expires attribute to current date:

          @GET
          @Path("get0")
          public Response get0() {
              System.out.println("MyEndpoint get0 - Version 0 Cookie");
              NewCookie cookie = new NewCookie("Name", "Value", "/", "*", 0, "comment", 3600, new Date(),
                      true, true);
              return Response.ok().cookie(cookie).entity(cookie.toString()).build();
          }  
      
          @GET
          @Path("get1")
          public Response get1() {
              System.out.println("MyEndpoint get1 - Version 1 Cookie");
              NewCookie cookie = new NewCookie("Name", "Value", "/", "*", 1, "comment", 3600, new Date(),
                      true, true);
              return Response.ok().cookie(cookie).entity(cookie.toString()).build();
          }  
      

      V0 Cookie set Expires attribute but it's not same to a specified time (current date). It looks calculated from Max-Age attribute:

      $ curl -v localhost:8080/myapp/rest/get0
      > GET /myapp/rs/get0 HTTP/1.1
      > ...
      >
      < HTTP/1.1 200 OK
      < ...
      < Set-Cookie: Name=Value; path=/; domain=*; secure; HttpOnly; Max-Age=3600; Expires=Mon, 22-Aug-2016 01:12:52 GMT
      < ...
      < Date: Mon, 22 Aug 2016 00:12:52 GMT
      <
      Name=Value;Version=0;Comment=comment;Domain=*;Path=/;Max-Age=3600;Expires=Mon, 22-Aug-2016 00:12:52 GMT;Secure;HttpOnly
      

      V1 Cookie does not set Expires attribute:

      $ curl -v localhost:8080/myapp/rest/get1
      > GET /myapp/rs/get1 HTTP/1.1
      > ...
      >
      < HTTP/1.1 200 OK
      < ...
      < Set-Cookie: Name=Value; Version=1; Path=/; Domain=*; Secure; HttpOnly; Max-Age=3600
      < ...
      < Date: Mon, 22 Aug 2016 00:12:55 GMT
      <
      Name=Value;Version=1;Comment=comment;Domain=*;Path=/;Max-Age=3600;Expires=Mon, 22-Aug-2016 00:12:55 GMT;Secure;HttpOnly
      

              rhn-support-ivassile Ilia Vassilev
              rhn-support-mmiura Masafumi Miura
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: