JETTY-1142 Replace Set-Cookies with same name
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1683 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
cc6b89040f
commit
2f2c9cbe14
|
@ -20,6 +20,7 @@ jetty-7.1.0.RC1-SNAPSHOT
|
|||
+ 311362 Optional org.eclipse.jetty.util.log.stderr.SOURCE
|
||||
+ 308864 Update test suite to JUnit4 - Module jetty-servlets
|
||||
+ JETTY-1030 - Improve jetty.sh script
|
||||
+ JETTY-1142 Replace Set-Cookies with same name
|
||||
|
||||
jetty-7.1.0.RC0 27 April 2010
|
||||
+ 294563 Websocket client connection
|
||||
|
|
|
@ -983,6 +983,7 @@ public class HttpFields
|
|||
String name_value_params;
|
||||
QuotedStringTokenizer.quoteIfNeeded(buf, name);
|
||||
buf.append('=');
|
||||
String start=buf.toString();
|
||||
if (value != null && value.length() > 0)
|
||||
QuotedStringTokenizer.quoteIfNeeded(buf, value);
|
||||
|
||||
|
@ -1039,6 +1040,24 @@ public class HttpFields
|
|||
// TODO - straight to Buffer?
|
||||
name_value_params = buf.toString();
|
||||
put(HttpHeaders.EXPIRES_BUFFER, __01Jan1970_BUFFER);
|
||||
|
||||
// look for existing cookie
|
||||
Field field = getField(HttpHeaders.SET_COOKIE_BUFFER);
|
||||
if (field != null)
|
||||
{
|
||||
final int revision=_revision;
|
||||
|
||||
while (field!=null)
|
||||
{
|
||||
if (field._revision!=revision || field._value!=null && field._value.toString().startsWith(start))
|
||||
{
|
||||
field.reset(new ByteArrayBuffer(name_value_params),-1,revision);
|
||||
return;
|
||||
}
|
||||
field=field._next;
|
||||
}
|
||||
}
|
||||
|
||||
add(HttpHeaders.SET_COOKIE_BUFFER, new ByteArrayBuffer(name_value_params));
|
||||
}
|
||||
|
||||
|
|
|
@ -379,6 +379,19 @@ public class HttpFieldsTest extends TestCase
|
|||
fields.addSetCookie("json","{\"services\":[\"cwa\", \"aa\"]}",null,null,-1,null,false,false,-1);
|
||||
assertEquals("json=\"{\\\"services\\\":[\\\"cwa\\\", \\\"aa\\\"]}\"",fields.getStringField("Set-Cookie"));
|
||||
|
||||
fields.clear();
|
||||
fields.addSetCookie("name","value","domain",null,-1,null,false,false,-1);
|
||||
fields.addSetCookie("name","other","domain",null,-1,null,false,false,-1);
|
||||
assertEquals("name=other;Domain=domain",fields.getStringField("Set-Cookie"));
|
||||
fields.addSetCookie("name","more","domain",null,-1,null,false,false,-1);
|
||||
assertEquals("name=more;Domain=domain",fields.getStringField("Set-Cookie"));
|
||||
fields.addSetCookie("foo","bar","domain",null,-1,null,false,false,-1);
|
||||
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");
|
||||
assertEquals("name=more;Domain=domain",e.nextElement());
|
||||
assertEquals("foo=bob;Domain=domain",e.nextElement());
|
||||
}
|
||||
|
||||
private Set enum2set(Enumeration e)
|
||||
|
|
Loading…
Reference in New Issue