本文整理匯總了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);
}