From 834d466879a99fcfe64c20ec2622dcbc2142ded3 Mon Sep 17 00:00:00 2001 From: r4v3zn Date: Mon, 24 Oct 2022 10:46:15 +0800 Subject: [PATCH] =?UTF-8?q?fixup!=20=E6=96=87=E4=BB=B6=E5=90=8D=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=8F=90=E5=8F=96=E5=A4=B1=E8=B4=A5=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8F=90=E5=8F=96=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/hutool/http/HttpResponse.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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 a4439b527..b994053f0 100755 --- a/hutool-http/src/main/java/cn/hutool/http/HttpResponse.java +++ b/hutool-http/src/main/java/cn/hutool/http/HttpResponse.java @@ -622,15 +622,25 @@ public class HttpResponse extends HttpBase implements Closeable { } /** - * 从Content-Disposition头中获取文件名 + * 从Content-Disposition头中获取文件名,默认为 filename * * @return 文件名,empty表示无 */ private String getFileNameFromDisposition() { + return getFileNameFromDisposition("filename"); + } + + /** + * 从Content-Disposition头中获取文件名 + * @param paramName 文件参数名 + * + * @return 文件名,empty表示无 + */ + private String getFileNameFromDisposition(String paramName) { String fileName = null; final String disposition = header(Header.CONTENT_DISPOSITION); if (StrUtil.isNotBlank(disposition)) { - fileName = ReUtil.get("filename=\"(.*?)\"", disposition, 1); + fileName = ReUtil.get(paramName+"=\"(.*?)\"", disposition, 1); if (StrUtil.isBlank(fileName)) { fileName = StrUtil.subAfter(disposition, "filename=", true); }