private Map<URI, List<SerializableCookie>> exportCookies() { Map<URI, List<SerializableCookie>> preserializedCookies = new HashMap<URI, List<SerializableCookie>>(); for (URI uri : store.getURIs()) { preserializedCookies.put(uri, SerializableHttpCookieAdapter.serialize(store.get(uri))); } return preserializedCookies; }
@Override public List<HttpCookie> get(URI uri) { List<HttpCookie> cookies = store.get(uri); if (logVerbose) { Log.i(LOG_TAG, "get(URI " + uri + ") - " + cookies); } return cookies; }
@Override public void beforeRequest(Map<String, List<String>> headers) { CookieStore cookieStore = getCookieStore(); List<HttpCookie> cookies = cookieStore.get(URI.create(getURL())); if (!cookies.isEmpty()) { List<String> cookieHeader = headers.get("Cookie"); if (cookieHeader == null) cookieHeader = headers.get("cookie"); if (cookieHeader == null) headers.put("Cookie", cookieHeader = new ArrayList<>()); for (HttpCookie cookie : cookies) cookieHeader.add(cookie.getName() + "=" + cookie.getValue()); } }