From 8dbb228617b51e80cc781bed9ddd78a73ead43c1 Mon Sep 17 00:00:00 2001 From: kl Date: Mon, 28 Dec 2020 11:42:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=95=E5=85=A5galimatias,=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E4=B8=8D=E8=A7=84=E8=8C=83=E6=96=87=E4=BB=B6=E5=90=8D=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/pom.xml | 6 ++++++ server/src/main/java/cn/keking/utils/DownloadUtils.java | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/server/pom.xml b/server/pom.xml index c0eda0e8..064ff85e 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -201,6 +201,12 @@ system ${basedir}/lib/cpdetector-1.04.jar + + + io.mola.galimatias + galimatias + 0.2.1 + diff --git a/server/src/main/java/cn/keking/utils/DownloadUtils.java b/server/src/main/java/cn/keking/utils/DownloadUtils.java index b46cac82..6c48d81c 100644 --- a/server/src/main/java/cn/keking/utils/DownloadUtils.java +++ b/server/src/main/java/cn/keking/utils/DownloadUtils.java @@ -4,6 +4,7 @@ import cn.keking.config.ConfigConstants; import cn.keking.model.FileAttribute; import cn.keking.model.FileType; import cn.keking.model.ReturnResponse; +import io.mola.galimatias.GalimatiasParseException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -81,7 +82,6 @@ public class DownloadUtils { public static byte[] getBytesFromUrl(String urlStr) throws IOException { InputStream is = getInputStreamFromUrl(urlStr); if (is == null) { - // urlStr = URLUtil.normalize(urlStr, true, true); is = getInputStreamFromUrl(urlStr); if (is == null) { logger.error("文件下载异常:url:{}", urlStr); @@ -98,13 +98,14 @@ public class DownloadUtils { private static InputStream getInputStreamFromUrl(String urlStr) { try { - URL url = new URL(urlStr); + + URL url = io.mola.galimatias.URL.parse(urlStr).toJavaURL(); URLConnection connection = url.openConnection(); if (connection instanceof HttpURLConnection) { connection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); } return connection.getInputStream(); - } catch (IOException e) { + } catch (IOException | GalimatiasParseException e) { logger.warn("连接url异常:url:{}", urlStr); return null; }