diff --git a/CHANGELOG.md b/CHANGELOG.md index 96ff2f7cb..916243740 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * 【crypto】 Sign增加setParameter方法 * 【extra】 Sftp得put方法增加进度支持(issue#518@Github) * 【core】 ArrayUtil增加distinct方法 +* 【http】 去除log模块依赖,Cookie中去除日志提示,body方法传入JSON对象废弃,未来移除json模块依赖 ### Bug修复 diff --git a/hutool-http/pom.xml b/hutool-http/pom.xml index 26baf497f..cdde883c2 100644 --- a/hutool-http/pom.xml +++ b/hutool-http/pom.xml @@ -22,11 +22,6 @@ hutool-core ${project.parent.version} - - cn.hutool - hutool-log - ${project.parent.version} - cn.hutool hutool-json diff --git a/hutool-http/src/main/java/cn/hutool/http/HTMLFilter.java b/hutool-http/src/main/java/cn/hutool/http/HTMLFilter.java index 3b2dc82d2..379c241c0 100644 --- a/hutool-http/src/main/java/cn/hutool/http/HTMLFilter.java +++ b/hutool-http/src/main/java/cn/hutool/http/HTMLFilter.java @@ -10,7 +10,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.regex.Matcher; import java.util.regex.Pattern; -import cn.hutool.log.StaticLog; +import cn.hutool.core.lang.Console; /** * @@ -182,7 +182,7 @@ public final class HTMLFilter { private void debug(final String msg) { if (vDebug) { - StaticLog.debug(msg); + Console.log(msg); } } diff --git a/hutool-http/src/main/java/cn/hutool/http/HttpConnection.java b/hutool-http/src/main/java/cn/hutool/http/HttpConnection.java index db6663fbe..feb8b0dae 100644 --- a/hutool-http/src/main/java/cn/hutool/http/HttpConnection.java +++ b/hutool-http/src/main/java/cn/hutool/http/HttpConnection.java @@ -26,8 +26,6 @@ import cn.hutool.core.util.URLUtil; import cn.hutool.http.ssl.AndroidSupportSSLFactory; import cn.hutool.http.ssl.SSLSocketFactoryBuilder; import cn.hutool.http.ssl.TrustAnyHostnameVerifier; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; /** * http连接对象,对HttpURLConnection的包装 @@ -36,7 +34,6 @@ import cn.hutool.log.LogFactory; * */ public class HttpConnection { - private final static Log log = LogFactory.get(); private URL url; private Proxy proxy; @@ -343,7 +340,6 @@ public class HttpConnection { */ public HttpConnection setCookie(String cookie) { if (cookie != null) { - log.debug("With Cookie: {}", cookie); header(Header.COOKIE, cookie, true); } return this; diff --git a/hutool-http/src/main/java/cn/hutool/http/HttpRequest.java b/hutool-http/src/main/java/cn/hutool/http/HttpRequest.java index 01ad928b8..399769d6b 100644 --- a/hutool-http/src/main/java/cn/hutool/http/HttpRequest.java +++ b/hutool-http/src/main/java/cn/hutool/http/HttpRequest.java @@ -37,7 +37,6 @@ import cn.hutool.core.util.URLUtil; import cn.hutool.http.cookie.GlobalCookieManager; import cn.hutool.http.ssl.SSLSocketFactoryBuilder; import cn.hutool.json.JSON; -import cn.hutool.log.StaticLog; /** * http请求类
@@ -608,7 +607,13 @@ public class HttpRequest extends HttpBase { // ---------------------------------------------------------------- Body start /** - * 设置内容主体 + * 设置内容主体
+ * 请求体body参数支持两种类型: + * + *
+	 * 1. 标准参数,例如 a=1&b=2 这种格式
+	 * 2. Rest模式,此时body需要传入一个JSON或者XML字符串,Hutool会自动绑定其对应的Content-Type
+	 * 
* * @param body 请求体 * @return this @@ -664,7 +669,9 @@ public class HttpRequest extends HttpBase { * * @param json JSON请求体 * @return this + * @deprecated 未来可能去除此方法,使用{@link #body(String)} 传入JSON字符串即可 */ + @Deprecated public HttpRequest body(JSON json) { return this.body(json.toString()); } @@ -993,8 +1000,6 @@ public class HttpRequest extends HttpBase { if (redirectCount < this.maxRedirectCount) { redirectCount++; return execute(); - } else { - StaticLog.warn("URL [{}] redirect count more than {} !", this.url, this.maxRedirectCount); } } } diff --git a/hutool-http/src/main/java/cn/hutool/http/HttpResponse.java b/hutool-http/src/main/java/cn/hutool/http/HttpResponse.java index 1e2c7cf4f..0456f202e 100644 --- a/hutool-http/src/main/java/cn/hutool/http/HttpResponse.java +++ b/hutool-http/src/main/java/cn/hutool/http/HttpResponse.java @@ -24,7 +24,6 @@ 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.log.StaticLog; /** * Http响应类
@@ -386,7 +385,8 @@ public class HttpResponse extends HttpBase implements Closeable { try { this.headers = httpConnection.headers(); } catch (IllegalArgumentException e) { - StaticLog.warn(e, e.getMessage()); + // ignore + // StaticLog.warn(e, e.getMessage()); } // 存储服务端设置的Cookie信息 diff --git a/hutool-http/src/main/java/cn/hutool/http/cookie/GlobalCookieManager.java b/hutool-http/src/main/java/cn/hutool/http/cookie/GlobalCookieManager.java index e3f0b322f..e2ee735e3 100644 --- a/hutool-http/src/main/java/cn/hutool/http/cookie/GlobalCookieManager.java +++ b/hutool-http/src/main/java/cn/hutool/http/cookie/GlobalCookieManager.java @@ -8,13 +8,8 @@ import java.util.List; import java.util.Map; import cn.hutool.core.io.IORuntimeException; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.URLUtil; -import cn.hutool.http.Header; import cn.hutool.http.HttpConnection; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; /** * 全局Cooki管理器,只针对Hutool请求有效 @@ -23,7 +18,6 @@ import cn.hutool.log.LogFactory; * @since 4.5.15 */ public class GlobalCookieManager { - private static Log log = LogFactory.get(); /** Cookie管理 */ private static CookieManager cookieManager; @@ -67,10 +61,6 @@ public class GlobalCookieManager { throw new IORuntimeException(e); } - if(log.isDebugEnabled() && MapUtil.isNotEmpty(cookieHeader)) { - log.debug("Add Cookie from local store: {}", cookieHeader.get(Header.COOKIE.toString())); - } - // 不覆盖模式回填Cookie头,这样用户定义的Cookie将优先 conn.header(cookieHeader, false); } @@ -86,13 +76,6 @@ public class GlobalCookieManager { return; } - if(log.isDebugEnabled()) { - String setCookie = conn.header(Header.SET_COOKIE); - if(StrUtil.isNotEmpty(setCookie)) { - log.debug("Store Cookie: {}", setCookie); - } - } - try { cookieManager.put(URLUtil.toURI(conn.getUrl()), conn.headers()); } catch (IOException e) { diff --git a/hutool-http/src/test/java/cn/hutool/http/test/RestTest.java b/hutool-http/src/test/java/cn/hutool/http/test/RestTest.java index 2909ef5a7..1850ef944 100644 --- a/hutool-http/src/test/java/cn/hutool/http/test/RestTest.java +++ b/hutool-http/src/test/java/cn/hutool/http/test/RestTest.java @@ -18,6 +18,7 @@ import cn.hutool.json.JSONUtil; public class RestTest { @Test + @SuppressWarnings("deprecation") public void contentTypeTest() { HttpRequest request = HttpRequest.post("http://localhost:8090/rest/restTest/")// .body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2")); @@ -26,6 +27,7 @@ public class RestTest { @Test @Ignore + @SuppressWarnings("deprecation") public void postTest() { HttpRequest request = HttpRequest.post("http://localhost:8090/rest/restTest/")// .body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2")); @@ -42,6 +44,7 @@ public class RestTest { @Test @Ignore + @SuppressWarnings("deprecation") public void postTest3() { HttpRequest request = HttpRequest.post("http://211.162.39.204:8181/jeesite-simple/a/open/bizGwbnService/test")// .body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2")); diff --git a/pom.xml b/pom.xml index 9bfd1e94c..a93108a31 100644 --- a/pom.xml +++ b/pom.xml @@ -62,8 +62,8 @@ - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + Mulan Permissive Software License,Version 1 + http://license.coscl.org.cn/MulanPSL