Methods Summary |
---|
protected static java.lang.String | getDefaultDomain(org.apache.http.cookie.CookieOrigin origin)
return origin.getHost();
|
protected static java.lang.String | getDefaultPath(org.apache.http.cookie.CookieOrigin origin)
String defaultPath = origin.getPath();
int lastSlashIndex = defaultPath.lastIndexOf('/");
if (lastSlashIndex >= 0) {
if (lastSlashIndex == 0) {
//Do not remove the very first slash
lastSlashIndex = 1;
}
defaultPath = defaultPath.substring(0, lastSlashIndex);
}
return defaultPath;
|
public boolean | match(org.apache.http.cookie.Cookie cookie, org.apache.http.cookie.CookieOrigin origin)
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
}
if (origin == null) {
throw new IllegalArgumentException("Cookie origin may not be null");
}
for (CookieAttributeHandler handler: getAttribHandlers()) {
if (!handler.match(cookie, origin)) {
return false;
}
}
return true;
|
protected java.util.List | parse(org.apache.http.HeaderElement[] elems, org.apache.http.cookie.CookieOrigin origin)
List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
for (HeaderElement headerelement : elems) {
String name = headerelement.getName();
String value = headerelement.getValue();
if (name == null || name.length() == 0) {
throw new MalformedCookieException("Cookie name may not be empty");
}
BasicClientCookie cookie = new BasicClientCookie(name, value);
cookie.setPath(getDefaultPath(origin));
cookie.setDomain(getDefaultDomain(origin));
// cycle through the parameters
NameValuePair[] attribs = headerelement.getParameters();
for (int j = attribs.length - 1; j >= 0; j--) {
NameValuePair attrib = attribs[j];
String s = attrib.getName().toLowerCase(Locale.ENGLISH);
cookie.setAttribute(s, attrib.getValue());
CookieAttributeHandler handler = findAttribHandler(s);
if (handler != null) {
handler.parse(cookie, attrib.getValue());
}
}
cookies.add(cookie);
}
return cookies;
|
public void | validate(org.apache.http.cookie.Cookie cookie, org.apache.http.cookie.CookieOrigin origin)
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
}
if (origin == null) {
throw new IllegalArgumentException("Cookie origin may not be null");
}
for (CookieAttributeHandler handler: getAttribHandlers()) {
handler.validate(cookie, origin);
}
|