mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fox licene in pom and remove log for htttp
This commit is contained in:
parent
5e4718c8ce
commit
1caf64f4ac
@ -10,6 +10,7 @@
|
||||
* 【crypto】 Sign增加setParameter方法
|
||||
* 【extra】 Sftp得put方法增加进度支持(issue#518@Github)
|
||||
* 【core】 ArrayUtil增加distinct方法
|
||||
* 【http】 去除log模块依赖,Cookie中去除日志提示,body方法传入JSON对象废弃,未来移除json模块依赖
|
||||
|
||||
### Bug修复
|
||||
|
||||
|
@ -22,11 +22,6 @@
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-log</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-json</artifactId>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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请求类<br>
|
||||
@ -608,7 +607,13 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
|
||||
// ---------------------------------------------------------------- Body start
|
||||
/**
|
||||
* 设置内容主体
|
||||
* 设置内容主体<br>
|
||||
* 请求体body参数支持两种类型:
|
||||
*
|
||||
* <pre>
|
||||
* 1. 标准参数,例如 a=1&b=2 这种格式
|
||||
* 2. Rest模式,此时body需要传入一个JSON或者XML字符串,Hutool会自动绑定其对应的Content-Type
|
||||
* </pre>
|
||||
*
|
||||
* @param body 请求体
|
||||
* @return this
|
||||
@ -664,7 +669,9 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
*
|
||||
* @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<HttpRequest> {
|
||||
if (redirectCount < this.maxRedirectCount) {
|
||||
redirectCount++;
|
||||
return execute();
|
||||
} else {
|
||||
StaticLog.warn("URL [{}] redirect count more than {} !", this.url, this.maxRedirectCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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响应类<br>
|
||||
@ -386,7 +385,8 @@ public class HttpResponse extends HttpBase<HttpResponse> implements Closeable {
|
||||
try {
|
||||
this.headers = httpConnection.headers();
|
||||
} catch (IllegalArgumentException e) {
|
||||
StaticLog.warn(e, e.getMessage());
|
||||
// ignore
|
||||
// StaticLog.warn(e, e.getMessage());
|
||||
}
|
||||
|
||||
// 存储服务端设置的Cookie信息
|
||||
|
@ -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) {
|
||||
|
@ -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"));
|
||||
|
Loading…
Reference in New Issue
Block a user