當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。