rk
昨天 4a8ff39b0fab0627ef8f7459587d514cc01c3676
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.doumee.lib_coremodel.http.cookie;
 
 
import com.doumee.lib_coremodel.http.cookie.store.CookieStore;
 
import java.util.List;
 
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
 
/**
 * Created by goldze on 2017/5/13.
 */
public class CookieJarImpl implements CookieJar {
 
    private CookieStore cookieStore;
 
    public CookieJarImpl(CookieStore cookieStore) {
        if (cookieStore == null) {
            throw new IllegalArgumentException("cookieStore can not be null!");
        }
        this.cookieStore = cookieStore;
    }
 
    @Override
    public synchronized void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
        cookieStore.saveCookie(url, cookies);
    }
 
    @Override
    public synchronized List<Cookie> loadForRequest(HttpUrl url) {
        return cookieStore.loadCookie(url);
    }
 
    public CookieStore getCookieStore() {
        return cookieStore;
    }
}