Java:HttpClient 中的自动 cookie 处理?

发布于 2024-08-05 22:40:34 字数 318 浏览 5 评论 0原文

Java HttpClient 功能列表中,它表​​示:

自动 Cookie 处理以供读取 Set-Cookie:来自服务器的标头 并将它们通过 Cookie 发回: 适当时标头。

但我不知道如何使用这个功能。我只需要打开一个网页,让它设置所有 cookie,然后使用收到的 cookie 刷新同一页面。

谢谢。

In Java HttpClient feature list it says:

Automatic Cookie handling for reading
Set-Cookie: headers from the server
and sending them back out in a Cookie:
header when appropriate.

But I can't figure out how to use this feature. I just need to open a web page, let it set all the cookies, then refresh the same page with received cookies.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘香 2024-08-12 22:40:34

我不断从服务器返回错误,说我的客户端不支持 cookie,我应该打开它们。以下行停止了这些错误。希望这对你有用。

httpClient.setCookieStore(new BasicCookieStore());

I kept getting errors back from the server saying my client didn't support cookies and I should turn them on. The following line stopped those errors. Hope this works for you.

httpClient.setCookieStore(new BasicCookieStore());
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文