- @jroper's fix did not work, so I just fixed it again.
This commit is contained in:
Trustin Lee 2012-06-02 23:05:20 -07:00
parent 609674bda2
commit cc4c98d7ba
3 changed files with 39 additions and 22 deletions

View File

@ -113,7 +113,6 @@ public class CookieDecoder {
} }
Cookie c = new DefaultCookie(name, value); Cookie c = new DefaultCookie(name, value);
cookies.add(c);
boolean discard = false; boolean discard = false;
boolean secure = false; boolean secure = false;
@ -189,6 +188,8 @@ public class CookieDecoder {
c.setPorts(ports); c.setPorts(ports);
c.setDiscard(discard); c.setDiscard(discard);
} }
cookies.add(c);
} }
return cookies; return cookies;

View File

@ -271,23 +271,29 @@ public class DefaultCookie implements Cookie {
return false; return false;
} }
if (getPath() == null && that.getPath() != null) { if (getPath() == null) {
return false; if (that.getPath() != null) {
} else if (that.getPath() == null && getPath() != null) {
return false; return false;
} }
if (!getPath().equals(that.getPath())) { } else if (that.getPath() == null) {
return false;
} else if (!getPath().equals(that.getPath())) {
return false; return false;
} }
if (getDomain() == null && that.getDomain() != null) { if (getDomain() == null) {
return false; if (that.getDomain() != null) {
} else if (that.getDomain() == null && getDomain() != null) {
return false; return false;
} }
} else if (that.getDomain() == null) {
return false;
} else {
return getDomain().equalsIgnoreCase(that.getDomain()); return getDomain().equalsIgnoreCase(that.getDomain());
} }
return true;
}
@Override @Override
public int compareTo(Cookie c) { public int compareTo(Cookie c) {
int v; int v;
@ -296,25 +302,33 @@ public class DefaultCookie implements Cookie {
return v; return v;
} }
if (getPath() == null && c.getPath() != null) { if (getPath() == null) {
if (c.getPath() != null) {
return -1; return -1;
} else if (c.getPath() == null && getPath() != null) {
return 1;
} }
} else if (c.getPath() == null) {
return 1;
} else {
v = getPath().compareTo(c.getPath()); v = getPath().compareTo(c.getPath());
if (v != 0) { if (v != 0) {
return v; return v;
} }
if (getDomain() == null && c.getDomain() != null) {
return -1;
} else if (c.getDomain() == null && getDomain() != null) {
return 1;
} }
if (getDomain() == null) {
if (c.getDomain() != null) {
return -1;
}
} else if (c.getDomain() == null) {
return 1;
} else {
v = getDomain().compareToIgnoreCase(c.getDomain()); v = getDomain().compareToIgnoreCase(c.getDomain());
return v; return v;
} }
return 0;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();

View File

@ -233,6 +233,7 @@ public class CookieDecoderTest {
Iterator<Cookie> it = cookies.iterator(); Iterator<Cookie> it = cookies.iterator();
Cookie c; Cookie c;
assertTrue(it.hasNext());
c = it.next(); c = it.next();
assertEquals(1, c.getVersion()); assertEquals(1, c.getVersion());
assertEquals("session_id", c.getName()); assertEquals("session_id", c.getName());
@ -244,6 +245,7 @@ public class CookieDecoderTest {
assertTrue(c.getPorts().isEmpty()); assertTrue(c.getPorts().isEmpty());
assertEquals(-1, c.getMaxAge()); assertEquals(-1, c.getMaxAge());
assertTrue(it.hasNext());
c = it.next(); c = it.next();
assertEquals(1, c.getVersion()); assertEquals(1, c.getVersion());
assertEquals("session_id", c.getName()); assertEquals("session_id", c.getName());