{
// ---------------------------------------------------------------- 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