本文整理匯總了Java中org.apache.commons.httpclient.Cookie.setDomain方法的典型用法代碼示例。如果您正苦於以下問題:Java Cookie.setDomain方法的具體用法?Java Cookie.setDomain怎麽用?Java Cookie.setDomain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.httpclient.Cookie
的用法示例。
在下文中一共展示了Cookie.setDomain方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parse
import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
/**
* Parse cookie domain attribute.
*/
public void parse(final Cookie cookie, String domain)
throws MalformedCookieException {
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
}
if (domain == null) {
throw new MalformedCookieException(
"Missing value for domain attribute");
}
if (domain.trim().equals("")) {
throw new MalformedCookieException(
"Blank value for domain attribute");
}
domain = domain.toLowerCase();
if (!domain.startsWith(".")) {
// Per RFC 2965 section 3.2.2
// "... If an explicitly specified value does not start with
// a dot, the user agent supplies a leading dot ..."
// That effectively implies that the domain attribute
// MAY NOT be an IP address of a host name
domain = "." + domain;
}
cookie.setDomain(domain);
cookie.setDomainAttributeSpecified(true);
}
示例2: createCookieFromToken
import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
private Cookie createCookieFromToken(String token, String path, String domain)
{
Cookie cookie = new Cookie();
cookie.setPath(path);
cookie.setDomain(domain);
cookie.setName(token.substring(0, token.indexOf('=')));
cookie.setValue(token.substring(token.indexOf('=') + 1));
return cookie;
}
示例3: addCookie
import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
public synchronized void addCookie(Cookie cookie) {
if (cookie != null) {
if ("localhost.local".equals(cookie.getDomain())) {
cookie.setDomain("localhost");
}
super.addCookie(cookie);
}
}