本文整理汇总了Java中org.apache.http.client.CookieStore.clear方法的典型用法代码示例。如果您正苦于以下问题:Java CookieStore.clear方法的具体用法?Java CookieStore.clear怎么用?Java CookieStore.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.client.CookieStore
的用法示例。
在下文中一共展示了CookieStore.clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillSession
import org.apache.http.client.CookieStore; //导入方法依赖的package包/类
/**
* 将登录结果保存到给定会话对象中,并激活给定会话对象。
* @param session 会话对象
* @throws IllegalStateException 登录未成功时抛出
* @throws NetworkException 在发生网络问题时抛出
*/
public void fillSession(Session session) throws BiliLiveException {
try {
if (status != SUCCESS) throw new IllegalStateException("Bad status: " + status);
Set<Cookie> cookies = webClient.getCookieManager().getCookies();
CookieStore store = session.getCookieStore();
store.clear();
for (Cookie cookie : cookies) {
store.addCookie(cookie.toHttpClient()); // HtmlUnit Cookie to HttpClient Cookie
}
if (getStatus() == SUCCESS) session.activate();
} catch (IOException ex) {
throw new NetworkException("IO Exception", ex);
}
}
示例2: fromBase64
import org.apache.http.client.CookieStore; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void fromBase64(@NotNull Session session, @NonNls @NotNull String base64) {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64.getDecoder().decode(base64.getBytes()));
ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
List<Cookie> cookies = (List<Cookie>) objectInputStream.readObject();
CookieStore store = session.getCookieStore();
store.clear();
for (Cookie cookie : cookies) {
store.addCookie(cookie);
}
} catch (IOException | ClassNotFoundException e) {
throw new AssertionError();
}
}
示例3: testSuccessfulAuthAfterResettingCookieStore
import org.apache.http.client.CookieStore; //导入方法依赖的package包/类
@Test
public void testSuccessfulAuthAfterResettingCookieStore() {
ResponseEntity<String> result = authenticatedRestTemplate.getForEntity("", String.class);
Assert.assertEquals(HttpStatus.SC_OK, result.getStatusCode().value());
logger.debug("Muck with cookie store (ie. maybe a session got changed on a prevous random request");
CookieStore cookieStore = authenticatedRestTemplate.getRestTemplate().getCookieStore();
cookieStore.clear();
logger.debug("The subsequent request is still fine");
result = authenticatedRestTemplate.getForEntity("", String.class);
Assert.assertEquals(HttpStatus.SC_OK, result.getStatusCode().value());
}
示例4: cleanCookie
import org.apache.http.client.CookieStore; //导入方法依赖的package包/类
public static void cleanCookie(Context context){
CookieStore cookieStore = com.youzu.clan.base.net.CookieManager.getInstance().getCookieStore(context);
cookieStore.clear();
removeWebViewCookie(context);
}