如何获取HttpOnly cookie [英] How to get HttpOnly cookie

查看:2866
本文介绍了如何获取HttpOnly cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的Java代码中将HttpOnly cookie设置为Session cookie .
为了获得非HttpOnly cookie,我使用了Jsoup,但现在却卡在HttpOnly cookie中了?
注意: 不知道这是否重要,但是我要从中获取HttpCookies的网站是在ASP.net中开发的.

I need to get the HttpOnly cookies set as Session cookie in my java code.
To get non HttpOnly cookies I used Jsoup but now am stucked with HttpOnly cookies ?
Note : Don't know if it matters but the site from which I want to get HttpCookies is developed in ASP.net.

推荐答案

我希望Jsoup可以提供这些功能:

I would expect Jsoup to make those available:

Connection connection = Jsoup.connect("http://example.com");
Connection.Response response = connection.execute();

...然后在response上使用cookies映射.

...then use the cookies map on response.

如果不存在HttpOnly cookie,则可能必须直接读取URL的内容(例如,通过

If the HttpOnly cookies aren't there, you may have to read the contents of the URL directly (e.g., via URLConnection or similar) before passing them on to JSoup.parse, and look for the cookie headers in that stream.

侧面说明:要像上述连接后获得Document,而无需重复请求,请使用Connection#parse:

Side note: To get a Document after connecting as with the above, without repeating the request, use Connection#parse:

Document doc = connection.parse();

我之所以提及这一点,是因为您可能想要文档和cookie.

I just mention this because you're likely to want the document as well as the cookies.

这篇关于如何获取HttpOnly cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆