From c85f204da9445b58c2a42b06944812dc22ccf9c1 Mon Sep 17 00:00:00 2001 From: Looly Date: Fri, 26 Nov 2021 20:38:13 +0800 Subject: [PATCH] change code --- CHANGELOG.md | 3 ++- hutool-http/src/main/java/cn/hutool/http/HttpResponse.java | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8c3b0b9d..4a9ad47d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ------------------------------------------------------------------------------------------------------------- -# 5.7.17 (2021-11-24) +# 5.7.17 (2021-11-26) ### 🐣新特性 * 【core 】 增加AsyncUtil(pr#457@Gitee) @@ -25,6 +25,7 @@ * 【db 】 Db.executeBatch标记一个重载为弃用(issue#I4JIPH@Gitee) * 【core 】 增加CharSequenceUtil.subPreGbk重载(issue#I4JO2E@Gitee) * 【core 】 ReflectUtil.getMethod排除桥接方法(pr#1965@Github) +* 【http 】 completeFileNameFromHeader在使用path为路径时,自动解码(issue#I4K0FS@Gitee) * ### 🐞Bug修复 * 【core 】 修复FileResource构造fileName参数无效问题(issue#1942@Github) 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 f64f1ecd7..03ae911da 100644 --- a/hutool-http/src/main/java/cn/hutool/http/HttpResponse.java +++ b/hutool-http/src/main/java/cn/hutool/http/HttpResponse.java @@ -7,7 +7,6 @@ import cn.hutool.core.io.IORuntimeException; import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.StreamProgress; import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.URLUtil; @@ -434,7 +433,10 @@ public class HttpResponse extends HttpBase implements Closeable { fileName = StrUtil.subSuf(path, path.lastIndexOf('/') + 1); if (StrUtil.isBlank(fileName)) { // 编码后的路径做为文件名 - fileName = URLUtil.encodeQuery(path, CharsetUtil.CHARSET_UTF_8); + fileName = URLUtil.encodeQuery(path, charset); + } else { + // issue#I4K0FS@Gitee + fileName = URLUtil.decode(fileName, charset); } } return FileUtil.file(targetFileOrDir, fileName);