Java,让CookieHandler只作用于一个实例
我不知道 CookieHandler 在系统范围内是如何工作的,我确实查看了 CookieHandler 的源代码,但除了 get/set 方法之外没有找到更多信息。 TCP/HTTP 连接在哪里使用 CookieHandler 实例,我通过“
CookieHandler.setDefault(...)
我应该引用哪个源文件”设置该实例? URLConnection
& HttpURLConnection
似乎与它无关。
帮忙,先谢谢了。
Edit: Is it possible to apply CookieHandler to only one instance in which
setDefault
is invoked.I don't know how CookieHandler works system wide, I did view the source of CookieHandler but found no more information except the get/set methods. Where do TCP/HTTP connections use instance of CookieHandler, which I set by
CookieHandler.setDefault(...)
Which source file I should refer to? URLConnection
& HttpURLConnection
don't seem have things to do with it.
Help, thanks in advance.
Edit:
Is it possible to apply CookieHandler to only one instance in which
setDefault
is invoked.如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通过使用 this 来使其工作
,它在全局范围内安装
,但没有状态并委托给 a
,它在使用它的类中实例化,
例如
I got it working by using this
which gets installed globally
but has no state and delegate to a
which gets instantiated in the class where it gets used
like
java.net.CookieManager 的 javadoc 很好地概述了 CookieHandler 如何适应。
The javadoc for
java.net.CookieManager
gives a pretty good overview of how CookieHandler fits in.