/** * 获取Cookie * @return Cookie列表 * @since 3.1.1 */ public List<HttpCookie> getCookies(){ return HttpRequest.cookieManager.getCookieStore().getCookies(); }
/** * 获取Cookie * @return Cookie列表 * @since 3.1.1 */ public List<HttpCookie> getCookies(){ return HttpRequest.cookieManager.getCookieStore().getCookies(); }
@Override public List<HttpCookie> getCookies() { return getCookieStore().getCookies(); }
@Override public List<HttpCookie> getCookies() { return getCookieStore().getCookies(); }
/* init client */ HttpClient http = null; CookieStore httpCookieStore = new BasicCookieStore(); HttpClientBuilder builder = HttpClientBuilder.create().setDefaultCookieStore(httpCookieStore); http = builder.build(); /* do stuff */ HttpGet httpRequest = new HttpGet("http://stackoverflow.com/"); HttpResponse httpResponse = null; try {httpResponse = http.execute(httpRequest);} catch (Throwable error) {throw new RuntimeException(error);} /* check cookies */ httpCookieStore.getCookies();
public static HttpCookie getAuthCookie(CookieStore cookieStore, URI uri) { if (cookieStore == null) { return null; } boolean isSSL = "https".equals(uri.getScheme()); List<HttpCookie> cookies = cookieStore.getCookies(); for (HttpCookie c : cookies) { // If this is a secured cookie and the current connection is non-secured, // then, skip this cookie. We need to skip this cookie because, the cookie // replay will not be transmitted to the server. if (c.getSecure() && !isSSL) { continue; } if (c.getName().equals(AuthenticatedURL.AUTH_COOKIE)) { return c; } } return null; }
static HttpCookie getAuthCookie(CookieStore cookieStore, URI uri) { if (cookieStore == null) { return null; } boolean isSSL = uri.getScheme().equals("https"); List<HttpCookie> cookies = cookieStore.getCookies(); for (HttpCookie c : cookies) { // If this is a secured cookie and the current connection is non-secured, // then, skip this cookie. We need to skip this cookie because, the cookie // replay will not be transmitted to the server. if (c.getSecure() && !isSSL) { continue; } if (c.getName().equals(AuthenticatedURL.AUTH_COOKIE)) { return c; } } return null; }
logger.info("Hold cookie: %s.", cookieManager.getCookieStore().getCookies()); conn.setRequestProperty("Content-Type", httpClientRequest.getContentType()); conn.setRequestProperty("User-Agent", httpClientRequest.getUserAgent());
"No Auth Cookie found for URI[%s]. Existing Cookies[%s] Authenticating... ", uri, cookieManager.getCookieStore().getCookies() ); DruidKerberosUtil.authenticateIfRequired(internalClientPrincipal, internalClientKeytab);
cookieManager.getCookieStore().getCookies());
@Override public List<HttpCookie> getCookies() { return delegate.getCookies(); }
httpClient.execute(new HttpGet(uri)); CookieStore cookieStore = httpClient.getCookieStore(); List <Cookie> cookies = cookieStore.getCookies(); for (Cookie cookie: cookies) { if (cookie.getDomain().equals(Constants.CSRF_COOKIE_DOMAIN) && cookie.getName().equals("csrftoken")) { CSRFTOKEN = cookie.getValue(); } }
HttpClient httpClient = new DefaultHttpClient(); // execute get/post/put or whatever httpClient.doGetPostPutOrWhatever(); // get cookieStore CookieStore cookieStore = httpClient.getCookieStore(); // get Cookies List<Cookie> cookies = cookieStore.getCookies(); // process...
CookieStore cookieStore = sendPostData("www.mypage.com/login", "Username", "Password"); // Note, you may get more than one cookie, therefore this list. List<Cookie> cookie = cookieStore.getCookies(); // Grab the name of your cookie. String cookieOne = cookie.get(0).getName();
@Override public List<HttpCookie> getCookies() { return delegate.getCookies(); }
@Override public List<HttpCookie> getCookies() { return delegate.getCookies(); }
/** * 获取Cookie * @return Cookie列表 * @since 3.1.1 */ public List<HttpCookie> getCookies(){ return HttpRequest.cookieManager.getCookieStore().getCookies(); }
/** * 获取Cookie * @return Cookie列表 * @since 3.1.1 */ public List<HttpCookie> getCookies(){ return HttpRequest.cookieManager.getCookieStore().getCookies(); }
HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://192.168.178.163:8080/login/"); CookieStore cookieStore = new BasicCookieStore(); HttpContext context = new BasicHttpContext(); context.setAttribute(ClientContext.COOKIE_STORE, cookieStore); ... HttpResponse response = client.execute(post, context); List<Cookie> cookies = cookieStore.getCookies(); CookieMonster.eat(cookies); // :)
CookieStore cookieJar = Main.cookieManager.getCookieStore(); List<HttpCookie> cookies = cookieJar.getCookies(); for (HttpCookie ck: cookies) { if(ck.getName().equals("JSESSIONID")){ System.out.println("JSESSIONID"); }else{ ck.setMaxAge(0); System.out.println("CookieHandler retrieved cookie: " + ck); } }