浏览代码

add method

Looly 5 年之前
父节点
当前提交
ecedb5fd82

+ 3 - 1
CHANGELOG.md

@@ -3,10 +3,12 @@
 
 -------------------------------------------------------------------------------------------------------------
 
-# 5.4.5 (2020-09-30)
+# 5.4.5 (2020-10-09)
 
 ### 新特性
 * 【core   】     ConsoleTable代码优化(pr#190@Gitee)
+* 【http   】     HttpRequest增加setProxy重载(pr#190@Gitee)
+* 【http   】     XmlUtil.cleanComment(pr#191@Gitee)
 
 ### Bug修复
 

+ 4 - 3
hutool-core/src/main/java/cn/hutool/core/util/XmlUtil.java

@@ -72,7 +72,7 @@ public class XmlUtil {
 	/**
 	 * 在XML中注释的内容 正则
 	 */
-	public static final String NOTE_REGEX = "(?s)<!--.+?-->";
+	public static final String COMMENT_REGEX = "(?s)<!--.+?-->";
 	/**
 	 * XML格式化输出默认缩进量
 	 */
@@ -680,12 +680,13 @@ public class XmlUtil {
 	 *
 	 * @param xmlContent XML文本
 	 * @return 当传入为null时返回null
+	 * @since 5.4.5
 	 */
-	public static String cleanNote(String xmlContent) {
+	public static String cleanComment(String xmlContent) {
 		if (xmlContent == null) {
 			return null;
 		}
-		return xmlContent.replaceAll(NOTE_REGEX, "");
+		return xmlContent.replaceAll(COMMENT_REGEX, StrUtil.EMPTY);
 	}
 
 	/**

+ 2 - 2
hutool-core/src/test/java/cn/hutool/core/util/XmlUtilTest.java

@@ -212,9 +212,9 @@ public class XmlUtilTest {
 	}
 
 	@Test
-	public void cleanNoteTest() {
+	public void cleanCommentTest() {
 		final String xmlContent = "<info><title>hutool</title><!-- 这是注释 --><lang>java</lang></info>";
-		final String ret = XmlUtil.cleanNote(xmlContent);
+		final String ret = XmlUtil.cleanComment(xmlContent);
 		Assert.assertEquals("<info><title>hutool</title><lang>java</lang></info>", ret);
 	}
 

+ 15 - 0
hutool-http/src/main/java/cn/hutool/http/HttpRequest.java

@@ -28,6 +28,7 @@ import java.io.OutputStream;
 import java.net.CookieManager;
 import java.net.HttpCookie;
 import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
 import java.net.Proxy;
 import java.net.URLStreamHandler;
 import java.util.Collection;
@@ -842,6 +843,20 @@ public class HttpRequest extends HttpBase<HttpRequest> {
 	}
 
 	/**
+	 * 设置Http代理
+	 *
+	 * @param host 代理 主机
+	 * @param port 代理 端口
+	 * @return this
+	 * @since 5.4.5
+	 */
+	public HttpRequest setHttpProxy(String host, int port) {
+		final Proxy proxy = new Proxy(Proxy.Type.HTTP,
+				new InetSocketAddress(host, port));
+		return setProxy(proxy);
+	}
+
+	/**
 	 * 设置代理
 	 *
 	 * @param proxy 代理 {@link Proxy}