Android HttpClient和Cookies

Android HttpClient和Cookies,第1张

Android HttpClient和Cookies

我遇到了同样的问题,并且使用了与问题类似的方法,但是没有运气。对我来说起作用的是为每个复制的cookie添加域。(BasicClientcookie
cookie.setDomain(String))

我的效用函数

public static BasiccookieStore getcookieStore(String cookies, String domain) {    String[] cookievalues = cookies.split(";");    BasiccookieStore cs = new BasiccookieStore();    BasicClientcookie cookie;    for (int i = 0; i < cookievalues.length; i++) {        String[] split = cookievalues[i].split("=");        if (split.length == 2) cookie = new BasicClientcookie(split[0], split[1]);        else cookie = new BasicClientcookie(split[0], null);        cookie.setDomain(domain);        cs.addcookie(cookie);    }    return cs;} String cookies = cookieManager.getInstance().getcookie(url); BasiccookieStore lCS = getcookieStore(cookies, MyApp.sDomain); HttpContext localContext = new BasicHttpContext(); DefaultHttpClient httpclient = new DefaultHttpClient(); httpclient.setcookieStore(lCS); localContext.setAttribute(ClientContext.cookie_STORE, lCS); ...


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5426832.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存