Search in sources :

Example 86 with Cookie

use of com.firenio.codec.http11.Cookie in project OkHttp3 by MrZhousf.

the class PersistentCookieJar method loadForRequest.

@Override
public synchronized List<Cookie> loadForRequest(HttpUrl url) {
    List<Cookie> removedCookies = new ArrayList<>();
    List<Cookie> validCookies = new ArrayList<>();
    for (Iterator<Cookie> it = cache.iterator(); it.hasNext(); ) {
        Cookie currentCookie = it.next();
        if (isCookieExpired(currentCookie)) {
            removedCookies.add(currentCookie);
            it.remove();
        } else if (currentCookie.matches(url)) {
            validCookies.add(currentCookie);
        }
    }
    persistor.removeAll(removedCookies);
    return validCookies;
}
Also used : Cookie(okhttp3.Cookie) ArrayList(java.util.ArrayList)

Example 87 with Cookie

use of com.firenio.codec.http11.Cookie in project AndroidFrame by tongxiaoyun.

the class PersistentCookieJar method loadForRequest.

@Override
public synchronized List<Cookie> loadForRequest(HttpUrl url) {
    List<Cookie> cookiesToRemove = new ArrayList<>();
    List<Cookie> validCookies = new ArrayList<>();
    for (Iterator<Cookie> it = cache.iterator(); it.hasNext(); ) {
        Cookie currentCookie = it.next();
        if (isCookieExpired(currentCookie)) {
            cookiesToRemove.add(currentCookie);
            it.remove();
        } else if (currentCookie.matches(url)) {
            validCookies.add(currentCookie);
        }
    }
    persistor.removeAll(cookiesToRemove);
    return validCookies;
}
Also used : Cookie(okhttp3.Cookie) ArrayList(java.util.ArrayList)

Example 88 with Cookie

use of com.firenio.codec.http11.Cookie in project AndroidFrame by tongxiaoyun.

the class SharedPrefsCookiePersistor method loadAll.

@Override
public List<Cookie> loadAll() {
    List<Cookie> cookies = new ArrayList<>(sharedPreferences.getAll().size());
    for (Map.Entry<String, ?> entry : sharedPreferences.getAll().entrySet()) {
        String serializedCookie = (String) entry.getValue();
        Cookie cookie = new SerializableCookie().decode(serializedCookie);
        if (cookie != null) {
            cookies.add(cookie);
        }
    }
    return cookies;
}
Also used : Cookie(okhttp3.Cookie) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 89 with Cookie

use of com.firenio.codec.http11.Cookie in project AndroidFrame by tongxiaoyun.

the class SharedPrefsCookiePersistor method saveAll.

@Override
public void saveAll(Collection<Cookie> cookies) {
    SharedPreferences.Editor editor = sharedPreferences.edit();
    for (Cookie cookie : cookies) {
        editor.putString(createCookieKey(cookie), new SerializableCookie().encode(cookie));
    }
    editor.commit();
}
Also used : Cookie(okhttp3.Cookie) SharedPreferences(android.content.SharedPreferences)

Example 90 with Cookie

use of com.firenio.codec.http11.Cookie in project okhttp-OkGo by jeasonlzy.

the class MemoryCookieStore method saveCookie.

@Override
public synchronized void saveCookie(HttpUrl url, Cookie cookie) {
    List<Cookie> cookies = memoryCookies.get(url.host());
    List<Cookie> needRemove = new ArrayList<>();
    for (Cookie item : cookies) {
        if (cookie.name().equals(item.name())) {
            needRemove.add(item);
        }
    }
    cookies.removeAll(needRemove);
    cookies.add(cookie);
}
Also used : Cookie(okhttp3.Cookie) ArrayList(java.util.ArrayList)

Aggregations

Cookie (okhttp3.Cookie)102 ArrayList (java.util.ArrayList)31 IOException (java.io.IOException)20 HttpUrl (okhttp3.HttpUrl)18 ByteArrayInputStream (java.io.ByteArrayInputStream)16 ObjectInputStream (java.io.ObjectInputStream)16 SharedPreferences (android.content.SharedPreferences)12 Context (android.content.Context)8 HashMap (java.util.HashMap)8 List (java.util.List)8 Map (java.util.Map)8 Test (org.junit.Test)8 Response (okhttp3.Response)7 SerializableCookie (com.lzy.okgo.cookie.SerializableCookie)6 Request (okhttp3.Request)6 SuppressLint (android.annotation.SuppressLint)4 CookieManager (android.webkit.CookieManager)4 EhCookieStore (com.hippo.ehviewer.client.EhCookieStore)4 OnClick (butterknife.OnClick)3 SerializableCookie (com.franmontiel.persistentcookiejar.persistence.SerializableCookie)3