当前位置: 首页>>代码示例>>Java>>正文


Java HttpCookie.setVersion方法代码示例

本文整理汇总了Java中java.net.HttpCookie.setVersion方法的典型用法代码示例。如果您正苦于以下问题:Java HttpCookie.setVersion方法的具体用法?Java HttpCookie.setVersion怎么用?Java HttpCookie.setVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.HttpCookie的用法示例。


在下文中一共展示了HttpCookie.setVersion方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: initCookies

import java.net.HttpCookie; //导入方法依赖的package包/类
private void initCookies() {
    CookieManager cookieManager = new CookieManager();
    CookieHandler.setDefault(cookieManager);
    if (cookieManager.getCookieStore().getCookies().size() == 0) {
        try {
            String url = SharedPreferencesEditor.getInstance().getString(
                    Constants.PREFS_URL_SHORTCUT);
            URI uri = new URI(url);
            HttpCookie cookie = new HttpCookie(Constants.COOKIE_AUTH_NAME,
                    SharedPreferencesEditor.getInstance().getString(
                            Constants.PREFS_AUTH));
            cookie.setDomain(uri.getHost());
            cookie.setPath(Constants.COOKIE_BASE_PATH);
            cookie.setVersion(0);
            cookie.setMaxAge((new Date()).getTime()
                    + Constants.COOKIE_LIFETIME_YEAR);
            cookieManager.getCookieStore().add(uri, cookie);
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }

    }
}
 
开发者ID:CactusSoft,项目名称:zabbkit-android,代码行数:24,代码来源:GraphFragment.java

示例3: setLoadBalanceKey

import java.net.HttpCookie; //导入方法依赖的package包/类
private void setLoadBalanceKey(ClientUpgradeRequest request) {
    if (SDKConstants.CUPID_INTERACTION_SUB_PROTOCOL_CLIENT.equals(subProtocol)
            && loadBalanceHashKey != null) {
        // add hash_key cookie for load balance
        int cookieVersion = 0;
        String lbKey = loadBalanceHashKey;
        if (loadBalanceHashKey.contains("\"")) {
            cookieVersion = 1;
            lbKey = lbKey.replaceAll("\"", "");
        }
        HttpCookie cookie = new HttpCookie(SDKConstants.CUPID_INTERACTION_COOKIE_HASH_KEY, lbKey);
        cookie.setVersion(cookieVersion);
        request.getCookies().add(cookie);
    }
}
 
开发者ID:aliyun,项目名称:aliyun-cupid-sdk,代码行数:16,代码来源:WebSocketClient.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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.setVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。