Methods Summary |
---|
public synchronized void | addCookie(org.apache.http.cookie.Cookie cookie)Adds an {@link Cookie HTTP cookie}, replacing any existing equivalent cookies.
If the given cookie has already expired it will not be added, but existing
values will still be removed.
if (cookie != null) {
// first remove any old cookie that is equivalent
for (Iterator<Cookie> it = cookies.iterator(); it.hasNext();) {
if (cookieComparator.compare(cookie, it.next()) == 0) {
it.remove();
break;
}
}
if (!cookie.isExpired(new Date())) {
cookies.add(cookie);
}
}
|
public synchronized void | addCookies(org.apache.http.cookie.Cookie[] cookies)Adds an array of {@link Cookie HTTP cookies}. Cookies are added individually and
in the given array order. If any of the given cookies has already expired it will
not be added, but existing values will still be removed.
if (cookies != null) {
for (Cookie cooky : cookies) {
this.addCookie(cooky);
}
}
|
public synchronized void | clear()Clears all cookies.
cookies.clear();
|
public synchronized boolean | clearExpired(java.util.Date date)Removes all of {@link Cookie cookies} in this HTTP state
that have expired by the specified {@link java.util.Date date}.
if (date == null) {
return false;
}
boolean removed = false;
for (Iterator<Cookie> it = cookies.iterator(); it.hasNext();) {
if (it.next().isExpired(date)) {
it.remove();
removed = true;
}
}
return removed;
|
public synchronized java.util.List | getCookies()Returns an immutable array of {@link Cookie cookies} that this HTTP
state currently contains.
return Collections.unmodifiableList(this.cookies);
|
public java.lang.String | toString()
return cookies.toString();
|