From d623d6925c7ee3c3cd0db45d325b236bf0e2d0d2 Mon Sep 17 00:00:00 2001 From: Looly Date: Sat, 8 May 2021 07:40:39 +0800 Subject: [PATCH] add closeCookie --- CHANGELOG.md | 3 ++- .../src/main/java/cn/hutool/http/HttpUtil.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a19a63a2..74e3281ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,10 @@ ------------------------------------------------------------------------------------------------------------- -# 5.6.5 (2021-04-25) +# 5.6.5 (2021-05-08) ### 🐣新特性 +* 【http 】 HttpUtil增加closeCookie方法 ### 🐞Bug修倍 ------------------------------------------------------------------------------------------------------------- diff --git a/hutool-http/src/main/java/cn/hutool/http/HttpUtil.java b/hutool-http/src/main/java/cn/hutool/http/HttpUtil.java index 9384413ef..4be7ced26 100644 --- a/hutool-http/src/main/java/cn/hutool/http/HttpUtil.java +++ b/hutool-http/src/main/java/cn/hutool/http/HttpUtil.java @@ -13,11 +13,13 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.URLUtil; +import cn.hutool.http.cookie.GlobalCookieManager; import cn.hutool.http.server.SimpleServer; import java.io.File; import java.io.InputStream; import java.io.OutputStream; +import java.net.CookieManager; import java.net.HttpURLConnection; import java.nio.charset.Charset; import java.util.ArrayList; @@ -838,4 +840,14 @@ public class HttpUtil { final String data = username.concat(":").concat(password); return "Basic " + Base64.encode(data, charset); } + + /** + * 关闭Cookie + * + * @see GlobalCookieManager#setCookieManager(CookieManager) + * @since 5.6.5 + */ + public static void closeCookie() { + GlobalCookieManager.setCookieManager(null); + } }