@@ -0,0 +1,2511 @@
+package tw.idv.laiis.ezretrofit.cookies;%0A%0Aimport okhttp3.Cookie;%0Aimport okhttp3.CookieJar;%0Aimport okhttp3.HttpUrl;%0A%0Aimport java.net.CookieManager;%0Aimport java.net.CookiePolicy;%0Aimport java.net.CookieStore;%0Aimport java.net.HttpCookie;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Created by laiis on 2017/6/14.%0A */%0Apublic class CookieJarManager extends CookieManager implements CookieJar %7B%0A%0A    private static volatile CookiePolicy cookiePolicy;%0A%0A    public CookieJarManager(PersistentCookieStore store, CookiePolicy cookiePolicy) %7B%0A        super(store, cookiePolicy);%0A        this.cookiePolicy = cookiePolicy;%0A    %7D%0A%0A    @Override%0A    public void saveFromResponse(HttpUrl url, List%3CCookie%3E cookies) %7B%0A        if (cookiePolicy == null %7C%7C CookiePolicy.ACCEPT_NONE == cookiePolicy) %7B%0A            return;%0A        %7D%0A%0A        CookieStore cookieStore = getCookieStore();%0A        for (Cookie cookie : cookies) %7B%0A            HttpCookie httpCookie = new HttpCookie(cookie.name(), cookie.value());%0A            httpCookie.setDomain(cookie.domain());%0A            httpCookie.setMaxAge(cookie.expiresAt());%0A            httpCookie.setSecure(cookie.secure());%0A            httpCookie.setPath(cookie.path());%0A            httpCookie.setHttpOnly(cookie.httpOnly());%0A%0A            if (cookiePolicy.shouldAccept(url.uri(), httpCookie)) %7B%0A                cookieStore.add(url.uri(), httpCookie);%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Override%0A    public List%3CCookie%3E loadForRequest(HttpUrl url) %7B%0A        if (cookiePolicy == null %7C%7C CookiePolicy.ACCEPT_NONE == cookiePolicy) %7B%0A            return new ArrayList%3C%3E();%0A        %7D%0A%0A        CookieStore cookieStore = getCookieStore();%0A        List%3CHttpCookie%3E httpCookies = cookieStore.get(url.uri());%0A        List%3CCookie%3E cookies = new ArrayList%3C%3E();%0A        for (HttpCookie httpCookie : httpCookies) %7B%0A            Cookie cookie = new Cookie.Builder()%0A                    .domain(httpCookie.getDomain())%0A                    .expiresAt(httpCookie.getMaxAge())%0A                    .name(httpCookie.getName())%0A                    .value(httpCookie.getValue())%0A                    .path(httpCookie.getPath())%0A                    .build();%0A%0A            if (httpCookie.isHttpOnly()) %7B%0A                cookie.httpOnly();%0A            %7D%0A%0A            if (httpCookie.getSecure()) %7B%0A                cookie.secure();%0A            %7D%0A%0A            if (cookiePolicy.shouldAccept(url.uri(), httpCookie)) %7B%0A                cookies.add(cookie);%0A            %7D%0A        %7D%0A%0A        return cookies;%0A    %7D%0A%7D%0A

add CookieJarManager