當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpCookie.setCommentURL方法代碼示例

本文整理匯總了Java中java.net.HttpCookie.setCommentURL方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpCookie.setCommentURL方法的具體用法?Java HttpCookie.setCommentURL怎麽用?Java HttpCookie.setCommentURL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.net.HttpCookie的用法示例。


在下文中一共展示了HttpCookie.setCommentURL方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toHttpCookie

import java.net.HttpCookie; //導入方法依賴的package包/類
public HttpCookie toHttpCookie() {
    HttpCookie cookie = new HttpCookie(name, value);
    cookie.setComment(comment);
    cookie.setCommentURL(commentURL);
    cookie.setDiscard(discard);
    cookie.setDomain(domain);
    if (expiry == -1L) {
        cookie.setMaxAge(-1L);
    } else {
        cookie.setMaxAge((expiry - System.currentTimeMillis()) / 1000L);
    }
    cookie.setPath(path);
    cookie.setPortlist(portList);
    cookie.setSecure(secure);
    cookie.setVersion(version);
    return cookie;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:CookieEntity.java

示例2: readObject

import java.net.HttpCookie; //導入方法依賴的package包/類
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    cookie = new HttpCookie(name, value);
    cookie.setComment((String) in.readObject());
    cookie.setCommentURL((String) in.readObject());
    cookie.setDomain((String) in.readObject());
    cookie.setMaxAge(in.readLong());
    cookie.setPath((String) in.readObject());
    cookie.setPortlist((String) in.readObject());
    cookie.setVersion(in.readInt());
    cookie.setSecure(in.readBoolean());
    cookie.setDiscard(in.readBoolean());
    setHttpOnly(in.readBoolean());
}
 
開發者ID:abohomol,項目名稱:cookietray,代碼行數:16,代碼來源:SerializableCookie.java

示例3: createHttpCookie

import java.net.HttpCookie; //導入方法依賴的package包/類
private HttpCookie createHttpCookie() {
    HttpCookie cookie = new HttpCookie("name", "value");
    cookie.setPath("/");
    cookie.setComment("comment");
    cookie.setCommentURL("localhost");
    cookie.setDiscard(true);
    cookie.setDomain("home");
    cookie.setMaxAge(System.currentTimeMillis());
    cookie.setPortlist("42");
    cookie.setSecure(true);
    cookie.setVersion(1);
    return cookie;
}
 
開發者ID:abohomol,項目名稱:cookietray,代碼行數:14,代碼來源:SerializableCookieTest.java

示例4: toHttpCookie

import java.net.HttpCookie; //導入方法依賴的package包/類
/**
 * Convert to a new HttpCookie
 *
 * @return HttpCookie that have same contents
 * @throws IllegalStateException the name is null
 */
@NotNull
public HttpCookie toHttpCookie() {
    if (this.name == null) {
        throw new IllegalStateException("Illegal cookie name");
    }

    HttpCookie cookie = new HttpCookie(this.name, this.value);
    cookie.setComment(this.comment);
    cookie.setCommentURL(this.commentURL);
    cookie.setDiscard(this.toDiscard);
    cookie.setDomain(this.domain);
    cookie.setMaxAge(this.maxAge);
    cookie.setPath(this.path);
    cookie.setPortlist(this.portlist);
    cookie.setSecure(this.secure);
    cookie.setVersion(this.version);

    // for Android (API level 24)
    // https://developer.android.com/reference/java/net/HttpCookie.html#setHttpOnly(boolean)
    try {
        cookie.setHttpOnly(this.httpOnly);
    } catch (NoSuchMethodError e) {
    }

    return cookie;
}
 
開發者ID:emoji-gen,項目名稱:bottler,代碼行數:33,代碼來源:SerializableHttpCookie.java

示例5: testOf

import java.net.HttpCookie; //導入方法依賴的package包/類
@Test
public void testOf() {
    HttpCookie cookie = new HttpCookie("name", "value");
    cookie.setComment("comment");
    cookie.setCommentURL("commentURL");
    cookie.setDiscard(true);
    cookie.setDomain("example.com");
    cookie.setMaxAge(12345L);
    cookie.setPath("/");
    cookie.setPortlist("443");
    cookie.setSecure(true);
    cookie.setHttpOnly(true);
    cookie.setVersion(1);

    SerializableHttpCookie newCookie = SerializableHttpCookie.of(cookie);
    Assert.assertEquals(cookie.getName(), newCookie.getName());
    Assert.assertEquals(cookie.getValue(), newCookie.getValue());
    Assert.assertEquals(cookie.getComment(), newCookie.getComment());
    Assert.assertEquals(cookie.getCommentURL(), newCookie.getCommentURL());
    Assert.assertEquals(cookie.getDiscard(), newCookie.getDiscard());
    Assert.assertEquals(cookie.getDomain(), newCookie.getDomain());
    Assert.assertEquals(cookie.getMaxAge(), newCookie.getMaxAge());
    Assert.assertEquals(cookie.getPath(), newCookie.getPath());
    Assert.assertEquals(cookie.getPortlist(), newCookie.getPortlist());
    Assert.assertEquals(cookie.getSecure(), newCookie.getSecure());
    Assert.assertEquals(cookie.isHttpOnly(), newCookie.isHttpOnly());
    Assert.assertEquals(cookie.getVersion(), newCookie.getVersion());
}
 
開發者ID:emoji-gen,項目名稱:bottler,代碼行數:29,代碼來源:SerializableHttpCookieTest.java


注:本文中的java.net.HttpCookie.setCommentURL方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。