gpt4 book ai didi

httpclient - 如何从 Apache HttpClient 4.x 获取 cookie?

转载 作者:行者123 更新时间:2023-12-04 03:07:46 29 4
gpt4 key购买 nike

如何从 HttpClient 类型的现有对象获取 cookie?
我正在使用 HttpClient 版本 4.3.3,它不再有方法 httpClient.getCookieStore() 了。

最佳答案

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();
}

关于httpclient - 如何从 Apache HttpClient 4.x 获取 cookie?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22205320/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com