1.public static void asyncGetWithCookie(String url,String cookie,RequestParams params, AsyncHttpResponseHandler responseHandler) {
AsyncHttpClient ahc = new AsyncHttpClient();
ahc.addHeader("Cookie",cookie);
ahc.get(url, params, responseHandler);
AsyncHttpClient ahc = new AsyncHttpClient();
ahc.addHeader("Cookie",cookie);
ahc.get(url, params, responseHandler);
}
实际使用中发现如果不是重新new 一个AsyncHttpClient cookie可能带不上去,原因不详,所有遇到此情况考虑重新new 一个AsyncHttpClient
2. String[] cookiess = cookie.split("customkidswantsplit");
for (String cookies : cookiess){
cookieManager.setCookie(UrlUtil.HOST, cookies + ";Domain=" +UrlUtil.HOST);
}
}
cookieManager.setCookie(UrlUtil.HOST ,ExtraName.USER_STORAGE+"="+userJson + ";Domain=" +UrlUtil.HOST);
cookieManager.setCookie(UrlUtil.HOST, ExtraName.VERSION + "=" + version + ";Domain=" + UrlUtil.HOST);
cookie需要一个个setCookie,而不是把这些cookie拼接为一个很长的字符串