gpt4 book ai didi

java - 如何让 Apache HttpClient 尊重 Set-Cookie header 中的路径?

转载 作者:行者123 更新时间:2023-12-04 20:13:15 26 4
gpt4 key购买 nike

我有本地服务器在 /server/public 下运行端点和 /server/saml ,并且我正在使用 HttpClient (v4.4.1) 与之交互。对任何端点触发器的请求(如果客户端还没有 session ) header Set-Cookie: JSESSIONID=ABC123; Path=/server/ ,以便客户端应该有一个 session 。

但是,如果我调试并查看我的 BasicCookieStore 的内容,保存的 cookie 的路径为 /server/public/server/saml ,导致保存两个 cookie,并根据端点发送不同的 session cookie。

我正在使用标准 CookieSpec ,并使用标准严格查看相同的行为。

有什么想法发生了什么或我该如何解决?

最佳答案

问题似乎是由 this bug 引起的导致Path标题不被尊重。相反,客户端将删除从 URL 中检索响应的最后一个正斜杠之后的所有内容,并将其用作 cookie 的路径。 Scott Blum 的相关评论:

Namely, mixed-cased cookie attributes were not being handled properly. For example, if the Set-Cookie header being parsed contained a "Path=/foo" attribute, the path would not be respected at all. This is because the attributeHandler lookup would fail (it's keyed to "path").



将 httpclient 升级到 4.5 版解决了这个问题。

关于java - 如何让 Apache HttpClient 尊重 Set-Cookie header 中的路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32696035/

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