#63 patch for bug 1277797

closed
Wolfgang Fahl
None
5
2007-12-31
2005-10-20
Laurent Wozniak
No

created patch file for source code posted in comments
of bug 1277797

Date: 2005-09-05 17:06
Sender: lwozniak
Logged In: YES
user_id=719431

Discussion

  •  
    Attachments
  • Wolfgang Fahl
    Wolfgang Fahl
    2007-12-31

    Logged In: YES
    user_id=1220573
    Originator: NO

    Thank you for this patch.

    One can actually have some fun with this:-) See http://www.mnot.net/blog/2006/10/27/cookie_fun

    The following testCase checks the working of the changes:
    /**
    * test cookie age and expiration handling
    * see also Friday Fun: I Hate Cookies
    * http://www.mnot.net/blog/2006/10/27/cookie_fun
    * @throws Exception
    */
    public void testCookieAge() throws Exception {
    String ages[]= {"max-age=5000",
    "Max-Age=3000",
    "expires=Tue, 29-Mar-2005 19:30:42 GMT; Max-Age=2592000",
    "Max-Age=2592000;expires=Tue, 29-Mar-2005 19:30:42 GMT",
    "expires=Tue, 29-Mar-2005 19:30:42 GMT",
    "Expires=Wednesday, 01-Jan-1970 0:0:00 GMT"
    };
    long expectedMilliSeconds[]={System.currentTimeMillis()+5000*1000,
    System.currentTimeMillis()+3000*1000,
    1112124642000l,
    1112124642000l,
    1112124642000l,
    0};
    for (int i=0;i<ages.length;i++) {
    String index=""+i;
    String cookieName="cookie"+index.trim();
    String header=cookieName+"=cookievalue;"+ages[i];
    TestSource source=new TestSource(new URL("http://www.somedomain.com/somepath/"),header);
    CookieJar jar = new CookieJar(source);
    Cookie cookie=jar.getCookie(cookieName);
    assertTrue(cookieName+" not null",cookie!=null);
    if (cookie!=null) {
    long expiredTime=cookie.getExpiredTime();
    assertEquals(cookieName+" expiration",expiredTime,expectedMilliSeconds[i]);
    }
    }
    }

     
  • Wolfgang Fahl
    Wolfgang Fahl
    2007-12-31

    • assigned_to: nobody --> wolfgang_fahl
    • status: open --> closed