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


Java HttpCookie.hasExpired方法代码示例

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


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

示例1: getValidCookies

import java.net.HttpCookie; //导入方法依赖的package包/类
private List<HttpCookie> getValidCookies(URI uri) {
    List<HttpCookie> validCookies = new ArrayList<>();
    for (URI storedUri : cookiesCache.keySet()) {
        if (uriMatch(storedUri, uri)) {
            validCookies.addAll(cookiesCache.get(storedUri));
        }
    }

    Iterator<HttpCookie> it = validCookies.iterator();
    while (it.hasNext()) {
        HttpCookie cookie = it.next();
        if (cookie.hasExpired()) {
            removeFromPersistence(uri, cookie);
            cookiesCache.get(uri).remove(cookie);
            it.remove();
        }
    }
    return validCookies;
}
 
开发者ID:abohomol,项目名称:cookietray,代码行数:20,代码来源:CookieTray.java

示例2: main

import java.net.HttpCookie; //导入方法依赖的package包/类
public static void main(String... args) {
    HttpCookie cookie = new HttpCookie("testCookie", "value");
    cookie.setMaxAge(Integer.MIN_VALUE);
    if (cookie.hasExpired()) {
        throw new RuntimeException("Cookie has unexpectedly expired");
    }

    List<HttpCookie> cookies = HttpCookie.parse("Set-Cookie: " +
            "expiredCookie=value; expires=Thu, 01 Jan 1970 00:00:00 GMT");
    if (cookies.size() == 1) {
        if (cookies.get(0).getMaxAge() != 0) {
            throw new RuntimeException("Cookie maxAge expected to be 0");
        }
    } else {
        throw new RuntimeException("Header was incorrectly parsed");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:CookieNegativeMaxAge.java

示例3: getInternal2

import java.net.HttpCookie; //导入方法依赖的package包/类
private <T> void getInternal2(List<HttpCookie> cookies,
                            Map<T, List<HttpCookie>> cookieIndex,
                            Comparable<T> comparator, boolean secureLink)
{
    for (T index : cookieIndex.keySet()) {
        if (comparator.compareTo(index) == 0) {
            List<HttpCookie> indexedCookies = cookieIndex.get(index);
            // check the list of cookies associated with this domain
            if (indexedCookies != null) {
                Iterator<HttpCookie> it = indexedCookies.iterator();
                while (it.hasNext()) {
                    HttpCookie ck = it.next();
                    if (cookieJar.indexOf(ck) != -1) {
                        // the cookie still in main cookie store
                        if (!ck.hasExpired()) {
                            // don't add twice
                            if ((secureLink || !ck.getSecure()) &&
                                    !cookies.contains(ck))
                                cookies.add(ck);
                        } else {
                            it.remove();
                            cookieJar.remove(ck);
                        }
                    } else {
                        // the cookie has beed removed from main store,
                        // so also remove it from domain indexed store
                        it.remove();
                    }
                }
            } // end of indexedCookies != null
        } // end of comparator.compareTo(index) == 0
    } // end of cookieIndex iteration
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:InMemoryCookieStore.java


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