338364 Fixed expires header for set cookies
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3162 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
53417972ec
commit
c53749c232
|
@ -1,10 +1,12 @@
|
|||
jetty-7.4.2-SNAPSHOT
|
||||
+ 338364 Fixed expires header for set cookies
|
||||
+ 345729 binding for managing server and system classes globally
|
||||
+ 345615 Enable SSL Session caching
|
||||
+ 345763 Source file is updated during the build
|
||||
+ 345873 Update jetty-ssl.xml to new style
|
||||
+ 345900 Handle ipv6 with default port
|
||||
+ 346014 Fixed full HttpGenerator
|
||||
+ JETTY-1342 Recreate selector if wakeup throws JVM bug
|
||||
|
||||
jetty-7.4.1.v20110513
|
||||
+ 288563 remove unsupported and deprecated --secure option
|
||||
|
|
|
@ -80,6 +80,9 @@ public class HttpFields
|
|||
private final StringBuilder buf = new StringBuilder(32);
|
||||
private final GregorianCalendar gc = new GregorianCalendar(__GMT);
|
||||
|
||||
/**
|
||||
* Format HTTP date "EEE, dd MMM yyyy HH:mm:ss 'GMT'"
|
||||
*/
|
||||
public String formatDate(long date)
|
||||
{
|
||||
buf.setLength(0);
|
||||
|
@ -173,7 +176,6 @@ public class HttpFields
|
|||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Format HTTP date "EEE, dd MMM yyyy HH:mm:ss 'GMT'"
|
||||
* cookies
|
||||
*/
|
||||
public static String formatDate(long date)
|
||||
{
|
||||
|
@ -280,9 +282,10 @@ public class HttpFields
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
public final static String __01Jan1970=formatCookieDate(0);
|
||||
/* -------------------------------------------------------------- */
|
||||
public final static String __01Jan1970=formatDate(0);
|
||||
public final static Buffer __01Jan1970_BUFFER=new ByteArrayBuffer(__01Jan1970);
|
||||
public final static String __01Jan1970_COOKIE = formatCookieDate(0).trim();
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
private final ArrayList<Field> _fields = new ArrayList<Field>(20);
|
||||
|
@ -290,9 +293,6 @@ public class HttpFields
|
|||
private final int _maxCookieVersion;
|
||||
private int _revision;
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -1031,7 +1031,7 @@ public class HttpFields
|
|||
// Always add the expires param as some browsers still don't handle max-age
|
||||
buf.append(";Expires=");
|
||||
if (maxAge == 0)
|
||||
buf.append(__01Jan1970);
|
||||
buf.append(__01Jan1970_COOKIE);
|
||||
else
|
||||
formatCookieDate(buf, System.currentTimeMillis() + 1000L * maxAge);
|
||||
|
||||
|
@ -1051,10 +1051,9 @@ public class HttpFields
|
|||
if (isHttpOnly)
|
||||
buf.append(";HttpOnly");
|
||||
|
||||
// TODO - straight to Buffer?
|
||||
name_value_params = buf.toString();
|
||||
|
||||
// look for existing cookie
|
||||
// look for existing set cookie of same name
|
||||
Field field = getField(HttpHeaders.SET_COOKIE_BUFFER);
|
||||
if (field != null)
|
||||
{
|
||||
|
@ -1062,15 +1061,17 @@ public class HttpFields
|
|||
|
||||
while (field!=null)
|
||||
{
|
||||
if (field._revision!=revision || field._value!=null && field._value.toString().startsWith(start))
|
||||
if (field._revision==revision && field._value!=null && field._value.toString().startsWith(start))
|
||||
{
|
||||
field.reset(new ByteArrayBuffer(name_value_params),-1,revision);
|
||||
return;
|
||||
name_value_params=null;
|
||||
break;
|
||||
}
|
||||
field=field._next;
|
||||
}
|
||||
}
|
||||
|
||||
if (name_value_params!=null)
|
||||
add(HttpHeaders.SET_COOKIE_BUFFER, new ByteArrayBuffer(name_value_params));
|
||||
|
||||
// Expire responses with set-cookie headers so they do not get cached.
|
||||
|
|
|
@ -17,6 +17,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
|
@ -362,8 +363,15 @@ public class HttpFieldsTest
|
|||
assertEquals("minimal=value",fields.getStringField("Set-Cookie"));
|
||||
|
||||
fields.clear();
|
||||
fields.addSetCookie("everything","wrong","wrong","wrong",0,"to be replaced",true,true,0);
|
||||
fields.addSetCookie("everything","value","domain","path",0,"comment",true,true,0);
|
||||
assertEquals("everything=value;Path=path;Domain=domain;Expires=Thu, 01-Jan-1970 00:00:00 GMT;Secure;HttpOnly",fields.getStringField("Set-Cookie"));
|
||||
Enumeration<String> e =fields.getValues("Set-Cookie");
|
||||
assertTrue(e.hasMoreElements());
|
||||
assertEquals("everything=value;Path=path;Domain=domain;Expires=Thu, 01-Jan-1970 00:00:00 GMT;Secure;HttpOnly",e.nextElement());
|
||||
assertFalse(e.hasMoreElements());
|
||||
assertEquals("Thu, 01 Jan 1970 00:00:00 GMT",fields.getStringField("Expires"));
|
||||
|
||||
|
||||
fields.clear();
|
||||
fields.addSetCookie("ev erything","va lue","do main","pa th",1,"co mment",true,true,2);
|
||||
|
@ -394,7 +402,7 @@ public class HttpFieldsTest
|
|||
fields.addSetCookie("foo","bob","domain",null,-1,null,false,false,-1);
|
||||
assertEquals("name=more;Domain=domain",fields.getStringField("Set-Cookie"));
|
||||
|
||||
Enumeration e=fields.getValues("Set-Cookie");
|
||||
e=fields.getValues("Set-Cookie");
|
||||
assertEquals("name=more;Domain=domain",e.nextElement());
|
||||
assertEquals("foo=bob;Domain=domain",e.nextElement());
|
||||
|
||||
|
|
Loading…
Reference in New Issue