本文整理汇总了Java中com.loopj.android.http.AsyncHttpClient.getHttpContext方法的典型用法代码示例。如果您正苦于以下问题:Java AsyncHttpClient.getHttpContext方法的具体用法?Java AsyncHttpClient.getHttpContext怎么用?Java AsyncHttpClient.getHttpContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.loopj.android.http.AsyncHttpClient
的用法示例。
在下文中一共展示了AsyncHttpClient.getHttpContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cleanCookie
import com.loopj.android.http.AsyncHttpClient; //导入方法依赖的package包/类
public static void cleanCookie() {
// first clear store
// new PersistentCookieStore(AppContext.getInstance()).clear();
// clear header
AsyncHttpClient client = CLIENT;
if (client != null) {
HttpContext httpContext = client.getHttpContext();
CookieStore cookies = (CookieStore) httpContext
.getAttribute(HttpClientContext.COOKIE_STORE);
// 清理Async本地存储
if (cookies != null) {
cookies.clear();
}
// 清理当前正在使用的Cookie
client.removeHeader("Cookie");
}
log("cleanCookie");
}
示例2: getClientCookie
import com.loopj.android.http.AsyncHttpClient; //导入方法依赖的package包/类
/**
* 从AsyncHttpClient自带缓存中获取CookieString
*
* @param client AsyncHttpClient
* @return CookieString
*/
private static String getClientCookie(AsyncHttpClient client) {
String cookie = "";
if (client != null) {
HttpContext httpContext = client.getHttpContext();
CookieStore cookies = (CookieStore) httpContext
.getAttribute(HttpClientContext.COOKIE_STORE);
if (cookies != null && cookies.getCookies() != null && cookies.getCookies().size() > 0) {
for (Cookie c : cookies.getCookies()) {
cookie += (c.getName() + "=" + c.getValue()) + ";";
}
}
}
log("getClientCookie:" + cookie);
return cookie;
}