mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
ServletUtil遵循rfc 3986优化
This commit is contained in:
@@ -614,8 +614,9 @@ public class JakartaServletUtil {
|
||||
*/
|
||||
public static void write(HttpServletResponse response, InputStream in, String contentType, String fileName) {
|
||||
final String charset = ObjectUtil.defaultIfNull(response.getCharacterEncoding(), CharsetUtil.UTF_8);
|
||||
response.setHeader("Content-Disposition", StrUtil.format("attachment;filename=\"{}\"",
|
||||
URLUtil.encode(fileName, CharsetUtil.charset(charset))));
|
||||
final String encodeText = URLUtil.encodeAll(fileName, CharsetUtil.charset(charset));
|
||||
response.setHeader("Content-Disposition",
|
||||
StrUtil.format("attachment;filename=\"{}\";filename*={}''{}", encodeText, charset, encodeText));
|
||||
response.setContentType(contentType);
|
||||
write(response, in);
|
||||
}
|
||||
|
@@ -613,8 +613,9 @@ public class ServletUtil {
|
||||
*/
|
||||
public static void write(HttpServletResponse response, InputStream in, String contentType, String fileName) {
|
||||
final String charset = ObjectUtil.defaultIfNull(response.getCharacterEncoding(), CharsetUtil.UTF_8);
|
||||
response.setHeader("Content-Disposition", StrUtil.format("attachment;filename=\"{}\"",
|
||||
URLUtil.encode(fileName, CharsetUtil.charset(charset))));
|
||||
final String encodeText = URLUtil.encodeAll(fileName, CharsetUtil.charset(charset));
|
||||
response.setHeader("Content-Disposition",
|
||||
StrUtil.format("attachment;filename=\"{}\";filename*={}''{}", encodeText, charset, encodeText));
|
||||
response.setContentType(contentType);
|
||||
write(response, in);
|
||||
}
|
||||
|
Reference in New Issue
Block a user