- @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);
cookies.add(c);
boolean discard = false;
boolean secure = false;
@ -189,6 +188,8 @@ public class CookieDecoder {
c.setPorts(ports);
c.setDiscard(discard);
}
cookies.add(c);
}
return cookies;

View File

@ -271,21 +271,27 @@ public class DefaultCookie implements Cookie {
return false;
}
if (getPath() == null && that.getPath() != null) {
if (getPath() == null) {
if (that.getPath() != null) {
return false;
}
} else if (that.getPath() == null) {
return false;
} else if (that.getPath() == null && getPath() != null) {
return false;
}
if (!getPath().equals(that.getPath())) {
} else if (!getPath().equals(that.getPath())) {
return false;
}
if (getDomain() == null && that.getDomain() != null) {
return false;
} else if (that.getDomain() == null && getDomain() != null) {
if (getDomain() == null) {
if (that.getDomain() != null) {
return false;
}
} else if (that.getDomain() == null) {
return false;
} else {
return getDomain().equalsIgnoreCase(that.getDomain());
}
return getDomain().equalsIgnoreCase(that.getDomain());
return true;
}
@Override
@ -296,23 +302,31 @@ public class DefaultCookie implements Cookie {
return v;
}
if (getPath() == null && c.getPath() != null) {
return -1;
} else if (c.getPath() == null && getPath() != null) {
if (getPath() == null) {
if (c.getPath() != null) {
return -1;
}
} else if (c.getPath() == null) {
return 1;
} else {
v = getPath().compareTo(c.getPath());
if (v != 0) {
return v;
}
}
v = getPath().compareTo(c.getPath());
if (v != 0) {
if (getDomain() == null) {
if (c.getDomain() != null) {
return -1;
}
} else if (c.getDomain() == null) {
return 1;
} else {
v = getDomain().compareToIgnoreCase(c.getDomain());
return v;
}
if (getDomain() == null && c.getDomain() != null) {
return -1;
} else if (c.getDomain() == null && getDomain() != null) {
return 1;
}
v = getDomain().compareToIgnoreCase(c.getDomain());
return v;
return 0;
}
@Override

View File

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