How to get cookies from Apache HttpClient 4.x?

How to get cookies from an existing object of type HttpClient? I am using HttpClient version 4.3.3, which no longer has the httpClient.getCookieStore () method.

+6
source share
1 answer
CloseableHttpClient httpclient = HttpClients.createDefault(); HttpClientContext context = HttpClientContext.create(); CloseableHttpResponse response = httpclient.execute(new HttpGet("/"), context); try { CookieStore cookieStore = context.getCookieStore(); List<Cookie> cookies = cookieStore.getCookies(); } finally { response.close(); } 
+13
source

All Articles