private CookieStore getStore() { return client.getCookieStore(); }
public List<Cookie> getCookies() { if(sessionClient == null) return null; List<Cookie> cookies = sessionClient.getCookieStore().getCookies(); return cookies; }
static synchronized public List<Cookie> getGlobalCookies() { AbstractHttpClient client = new DefaultHttpClient(connmgr); List<Cookie> cookies = client.getCookieStore().getCookies(); return cookies; }
AbstractHttpClient client = new DefaultHttpClient(); //setup url Uri.Builder uriBuilder = Uri.parse(mRestUrl).buildUpon(); Uri uri = uriBuilder.build(); // request is either HttpPost or HttpGet request.setURI(new URI(uri.toString())); // Here we add cookies to cookie store of a client //(cookies saved manually) CookieStore cookieStore = client.getCookieStore(); for (Cookie cookie : cookieList) { cookieStore.addCookie(cookie); } HttpResponse response = client.execute(request); //in case you want to save cookies manually cookieList = client.getCookieStore().getCookies(); //response HttpEntity responseEntity = response.getEntity();
/** * 获取返回结果中的cookies信息 * @return */ private String getCookies(){ StringBuilder sb = new StringBuilder(); List<Cookie> cookies = ((AbstractHttpClient) httpClient).getCookieStore().getCookies(); for(Cookie cookie: cookies) sb.append(cookie.getName() + "=" + cookie.getValue() + ";"); return sb.toString(); }
public void reset() { client.getHttpClient().getCookieStore().clear(); }
private boolean hasValidatAuthenticationState() { List<Cookie> cookies = new ArrayList<Cookie>(getClient().getHttpClient().getCookieStore().getCookies()); if (cookies != null) { for (Cookie cookie : cookies) { if ("JSESSIONID".equals(cookie.getName())) { return !cookie.isExpired(new Date()); } } } return false; }
public void clearState() { sessionClient.getCredentialsProvider().clear(); sessionClient.getCookieStore().clear(); execcontext = new BasicHttpContext(); localsettings.clear(); authlocal.clear(); }
logger.info(">> login response cookies: \n" + client.getCookieStore().getCookies().toString()); } catch (Exception e) { logger.error("", e);
cookie = client.getCookieStore(); logger.info(">> login response content: \n" + content); logger.info(">> login response cookies: \n" + cookie.getCookies().toString());
login.setCookies(client.getCookieStore());
protected HttpContext createHttpContext() { final HttpContext context = new BasicHttpContext(); context.setAttribute( ClientContext.SCHEME_REGISTRY, getConnectionManager().getSchemeRegistry()); context.setAttribute( ClientContext.AUTHSCHEME_REGISTRY, getAuthSchemes()); context.setAttribute( ClientContext.COOKIESPEC_REGISTRY, getCookieSpecs()); context.setAttribute( ClientContext.COOKIE_STORE, getCookieStore()); context.setAttribute( ClientContext.CREDS_PROVIDER, getCredentialsProvider()); return context; }
protected HttpContext createHttpContext() { final HttpContext context = new BasicHttpContext(); context.setAttribute( ClientContext.SCHEME_REGISTRY, getConnectionManager().getSchemeRegistry()); context.setAttribute( ClientContext.AUTHSCHEME_REGISTRY, getAuthSchemes()); context.setAttribute( ClientContext.COOKIESPEC_REGISTRY, getCookieSpecs()); context.setAttribute( ClientContext.COOKIE_STORE, getCookieStore()); context.setAttribute( ClientContext.CREDS_PROVIDER, getCredentialsProvider()); return context; }
protected HttpContext createHttpContext() { final HttpContext context = new BasicHttpContext(); context.setAttribute( ClientContext.SCHEME_REGISTRY, getConnectionManager().getSchemeRegistry()); context.setAttribute( ClientContext.AUTHSCHEME_REGISTRY, getAuthSchemes()); context.setAttribute( ClientContext.COOKIESPEC_REGISTRY, getCookieSpecs()); context.setAttribute( ClientContext.COOKIE_STORE, getCookieStore()); context.setAttribute( ClientContext.CREDS_PROVIDER, getCredentialsProvider()); return context; }
protected HttpContext createHttpContext() { final HttpContext context = new BasicHttpContext(); context.setAttribute( ClientContext.SCHEME_REGISTRY, getConnectionManager().getSchemeRegistry()); context.setAttribute( ClientContext.AUTHSCHEME_REGISTRY, getAuthSchemes()); context.setAttribute( ClientContext.COOKIESPEC_REGISTRY, getCookieSpecs()); context.setAttribute( ClientContext.COOKIE_STORE, getCookieStore()); context.setAttribute( ClientContext.CREDS_PROVIDER, getCredentialsProvider()); return context; }