This commit is contained in:
Redkale
2019-10-25 11:42:50 +08:00
parent 40003c7789
commit d4fd093521

View File

@@ -855,7 +855,9 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
}
this.contentLength = length;
if (filename != null && !filename.isEmpty() && file != null) {
addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
if (this.header.getValue("Content-Disposition") == null) {
addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
}
}
this.contentType = MimeType.getByFilename(filename == null || filename.isEmpty() ? file.getName() : filename);
if (this.contentType == null) this.contentType = "application/octet-stream";