Browse Source

fox licene in pom and remove log for htttp

Looly 6 years ago
parent
commit
1caf64f4ac

+ 1 - 0
CHANGELOG.md

@@ -10,6 +10,7 @@
 * 【crypto】      Sign增加setParameter方法
 * 【crypto】      Sign增加setParameter方法
 * 【extra】        Sftp得put方法增加进度支持(issue#518@Github)
 * 【extra】        Sftp得put方法增加进度支持(issue#518@Github)
 * 【core】        ArrayUtil增加distinct方法
 * 【core】        ArrayUtil增加distinct方法
+* 【http】         去除log模块依赖,Cookie中去除日志提示,body方法传入JSON对象废弃,未来移除json模块依赖
 
 
 ### Bug修复
 ### Bug修复
 
 

+ 0 - 5
hutool-http/pom.xml

@@ -24,11 +24,6 @@
 		</dependency>
 		</dependency>
 		<dependency>
 		<dependency>
 			<groupId>cn.hutool</groupId>
 			<groupId>cn.hutool</groupId>
-			<artifactId>hutool-log</artifactId>
-			<version>${project.parent.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>cn.hutool</groupId>
 			<artifactId>hutool-json</artifactId>
 			<artifactId>hutool-json</artifactId>
 			<version>${project.parent.version}</version>
 			<version>${project.parent.version}</version>
 		</dependency>
 		</dependency>

+ 2 - 2
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.Matcher;
 import java.util.regex.Pattern;
 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) {
 	private void debug(final String msg) {
 		if (vDebug) {
 		if (vDebug) {
-			StaticLog.debug(msg);
+			Console.log(msg);
 		}
 		}
 	}
 	}
 
 

+ 0 - 4
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.AndroidSupportSSLFactory;
 import cn.hutool.http.ssl.SSLSocketFactoryBuilder;
 import cn.hutool.http.ssl.SSLSocketFactoryBuilder;
 import cn.hutool.http.ssl.TrustAnyHostnameVerifier;
 import cn.hutool.http.ssl.TrustAnyHostnameVerifier;
-import cn.hutool.log.Log;
-import cn.hutool.log.LogFactory;
 
 
 /**
 /**
  * http连接对象,对HttpURLConnection的包装
  * http连接对象,对HttpURLConnection的包装
@@ -36,7 +34,6 @@ import cn.hutool.log.LogFactory;
  *
  *
  */
  */
 public class HttpConnection {
 public class HttpConnection {
-	private final static Log log = LogFactory.get();
 
 
 	private URL url;
 	private URL url;
 	private Proxy proxy;
 	private Proxy proxy;
@@ -343,7 +340,6 @@ public class HttpConnection {
 	 */
 	 */
 	public HttpConnection setCookie(String cookie) {
 	public HttpConnection setCookie(String cookie) {
 		if (cookie != null) {
 		if (cookie != null) {
-			log.debug("With Cookie: {}", cookie);
 			header(Header.COOKIE, cookie, true);
 			header(Header.COOKIE, cookie, true);
 		}
 		}
 		return this;
 		return this;

+ 9 - 4
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.cookie.GlobalCookieManager;
 import cn.hutool.http.ssl.SSLSocketFactoryBuilder;
 import cn.hutool.http.ssl.SSLSocketFactoryBuilder;
 import cn.hutool.json.JSON;
 import cn.hutool.json.JSON;
-import cn.hutool.log.StaticLog;
 
 
 /**
 /**
  * http请求类<br>
  * http请求类<br>
@@ -608,7 +607,13 @@ public class HttpRequest extends HttpBase<HttpRequest> {
 
 
 	// ---------------------------------------------------------------- Body start
 	// ---------------------------------------------------------------- Body start
 	/**
 	/**
-	 * 设置内容主体
+	 * 设置内容主体<br>
+	 * 请求体body参数支持两种类型:
+	 * 
+	 * <pre>
+	 * 1. 标准参数,例如 a=1&amp;b=2 这种格式
+	 * 2. Rest模式,此时body需要传入一个JSON或者XML字符串,Hutool会自动绑定其对应的Content-Type
+	 * </pre>
 	 * 
 	 * 
 	 * @param body 请求体
 	 * @param body 请求体
 	 * @return this
 	 * @return this
@@ -664,7 +669,9 @@ public class HttpRequest extends HttpBase<HttpRequest> {
 	 * 
 	 * 
 	 * @param json JSON请求体
 	 * @param json JSON请求体
 	 * @return this
 	 * @return this
+	 * @deprecated 未来可能去除此方法,使用{@link #body(String)} 传入JSON字符串即可
 	 */
 	 */
+	@Deprecated
 	public HttpRequest body(JSON json) {
 	public HttpRequest body(JSON json) {
 		return this.body(json.toString());
 		return this.body(json.toString());
 	}
 	}
@@ -993,8 +1000,6 @@ public class HttpRequest extends HttpBase<HttpRequest> {
 					if (redirectCount < this.maxRedirectCount) {
 					if (redirectCount < this.maxRedirectCount) {
 						redirectCount++;
 						redirectCount++;
 						return execute();
 						return execute();
-					} else {
-						StaticLog.warn("URL [{}] redirect count more than {} !", this.url, this.maxRedirectCount);
 					}
 					}
 				}
 				}
 			}
 			}

+ 2 - 2
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.StrUtil;
 import cn.hutool.core.util.URLUtil;
 import cn.hutool.core.util.URLUtil;
 import cn.hutool.http.cookie.GlobalCookieManager;
 import cn.hutool.http.cookie.GlobalCookieManager;
-import cn.hutool.log.StaticLog;
 
 
 /**
 /**
  * Http响应类<br>
  * Http响应类<br>
@@ -386,7 +385,8 @@ public class HttpResponse extends HttpBase<HttpResponse> implements Closeable {
 		try {
 		try {
 			this.headers = httpConnection.headers();
 			this.headers = httpConnection.headers();
 		} catch (IllegalArgumentException e) {
 		} catch (IllegalArgumentException e) {
-			StaticLog.warn(e, e.getMessage());
+			// ignore
+			// StaticLog.warn(e, e.getMessage());
 		}
 		}
 
 
 		// 存储服务端设置的Cookie信息
 		// 存储服务端设置的Cookie信息

+ 0 - 17
hutool-http/src/main/java/cn/hutool/http/cookie/GlobalCookieManager.java

@@ -8,13 +8,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 import cn.hutool.core.io.IORuntimeException;
 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.core.util.URLUtil;
-import cn.hutool.http.Header;
 import cn.hutool.http.HttpConnection;
 import cn.hutool.http.HttpConnection;
-import cn.hutool.log.Log;
-import cn.hutool.log.LogFactory;
 
 
 /**
 /**
  * 全局Cooki管理器,只针对Hutool请求有效
  * 全局Cooki管理器,只针对Hutool请求有效
@@ -23,7 +18,6 @@ import cn.hutool.log.LogFactory;
  * @since 4.5.15
  * @since 4.5.15
  */
  */
 public class GlobalCookieManager {
 public class GlobalCookieManager {
-	private static Log log = LogFactory.get();
 
 
 	/** Cookie管理 */
 	/** Cookie管理 */
 	private static CookieManager cookieManager;
 	private static CookieManager cookieManager;
@@ -67,10 +61,6 @@ public class GlobalCookieManager {
 			throw new IORuntimeException(e);
 			throw new IORuntimeException(e);
 		}
 		}
 		
 		
-		if(log.isDebugEnabled() && MapUtil.isNotEmpty(cookieHeader)) {
-			log.debug("Add Cookie from local store: {}", cookieHeader.get(Header.COOKIE.toString()));
-		}
-		
 		// 不覆盖模式回填Cookie头,这样用户定义的Cookie将优先
 		// 不覆盖模式回填Cookie头,这样用户定义的Cookie将优先
 		conn.header(cookieHeader, false);
 		conn.header(cookieHeader, false);
 	}
 	}
@@ -86,13 +76,6 @@ public class GlobalCookieManager {
 			return;
 			return;
 		}
 		}
 		
 		
-		if(log.isDebugEnabled()) {
-			String setCookie = conn.header(Header.SET_COOKIE);
-			if(StrUtil.isNotEmpty(setCookie)) {
-				log.debug("Store Cookie: {}", setCookie);
-			}
-		}
-		
 		try {
 		try {
 			cookieManager.put(URLUtil.toURI(conn.getUrl()), conn.headers());
 			cookieManager.put(URLUtil.toURI(conn.getUrl()), conn.headers());
 		} catch (IOException e) {
 		} catch (IOException e) {

+ 3 - 0
hutool-http/src/test/java/cn/hutool/http/test/RestTest.java

@@ -18,6 +18,7 @@ import cn.hutool.json.JSONUtil;
 public class RestTest {
 public class RestTest {
 
 
 	@Test
 	@Test
+	@SuppressWarnings("deprecation")
 	public void contentTypeTest() {
 	public void contentTypeTest() {
 		HttpRequest request = HttpRequest.post("http://localhost:8090/rest/restTest/")//
 		HttpRequest request = HttpRequest.post("http://localhost:8090/rest/restTest/")//
 				.body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2"));
 				.body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2"));
@@ -26,6 +27,7 @@ public class RestTest {
 
 
 	@Test
 	@Test
 	@Ignore
 	@Ignore
+	@SuppressWarnings("deprecation")
 	public void postTest() {
 	public void postTest() {
 		HttpRequest request = HttpRequest.post("http://localhost:8090/rest/restTest/")//
 		HttpRequest request = HttpRequest.post("http://localhost:8090/rest/restTest/")//
 				.body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2"));
 				.body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2"));
@@ -42,6 +44,7 @@ public class RestTest {
 
 
 	@Test
 	@Test
 	@Ignore
 	@Ignore
+	@SuppressWarnings("deprecation")
 	public void postTest3() {
 	public void postTest3() {
 		HttpRequest request = HttpRequest.post("http://211.162.39.204:8181/jeesite-simple/a/open/bizGwbnService/test")//
 		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"));
 				.body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2"));

+ 2 - 2
pom.xml

@@ -62,8 +62,8 @@
 
 
 	<licenses>
 	<licenses>
 		<license>
 		<license>
-			<name>The Apache Software License, Version 2.0</name>
-			<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+			<name>Mulan Permissive Software License,Version 1</name>
+			<url>http://license.coscl.org.cn/MulanPSL</url>
 		</license>
 		</license>
 	</licenses>
 	</licenses>