解决抓不到SET-COOKIE里HttpOnly Cookie的问题(Java 7)

在sun.net.www.protocol.http.HttpURLConnection.filterHeaderField()里设定如果Cookie为HttpOnly而CookieHandler.getDefault()不是null的话,这个Cookie会被直接过滤掉。

一种解决的方法就是CookieHandler.setDefault(null)。或者使用自己的CookieHandler来读取Cookies。(注:setDefault函数需要new NetPermission(“getCookieHandler”)权限)

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s