use of com.koushikdutta.async.http.Headers in project ion by koush.
the class CookieTests method testReinit.
public void testReinit() throws Exception {
CookieMiddleware middleware = Ion.getDefault(getContext()).getCookieMiddleware();
Ion ion = Ion.getDefault(getContext());
ion.getCookieMiddleware().clear();
Headers headers = new Headers();
headers.set("Set-Cookie", "foo=bar");
URI uri = URI.create("http://example.com");
middleware.put(uri, headers);
headers.set("Set-Cookie", "poop=scoop");
middleware.put(uri, headers);
headers.set("Set-Cookie", "foo=goop");
middleware.put(uri, headers);
middleware.reinit();
CookieManager manager = middleware.getCookieManager();
Headers newHeaders = new Headers();
Map<String, List<String>> cookies = manager.get(uri, newHeaders.getMultiMap());
manager.get(uri, cookies);
CookieMiddleware.addCookies(cookies, newHeaders);
assertTrue(newHeaders.get("Cookie").contains("foo=goop"));
assertTrue(newHeaders.get("Cookie").contains("poop=scoop"));
assertFalse(newHeaders.get("Cookie").contains("bar"));
}
Aggregations