您从
HttpResponse response以下位置获取cookie :
Header[] mcookies = response.getHeaders("cookie");
HttpClient httpClient = new DefaultHttpClient();//parse name/value from mcookies[0]. If you have more than one cookie, a for cycle is needed.cookieStore cookieStore = new BasiccookieStore();cookie cookie = new BasicClientcookie("name", "value");cookieStore.addcookie(cookie);HttpContext localContext = new BasicHttpContext();localContext.setAttribute(ClientContext.cookie_STORE, cookieStore);HttpGet httpGet = new HttpGet("http://www.domain.com/");HttpResponse response = httpClient.execute(httpGet, localContext);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)