Fix header missing from raw e-mail download
This commit is contained in:
parent
3d2da43207
commit
8c4587f477
1 changed files with 11 additions and 1 deletions
|
@ -203,8 +203,13 @@ func handleGetPart(ctx *koushin.Context, raw bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if raw {
|
if raw {
|
||||||
|
ctx.Response().Header().Set("Content-Type", mimeType)
|
||||||
|
|
||||||
disp, dispParams, _ := part.Header.ContentDisposition()
|
disp, dispParams, _ := part.Header.ContentDisposition()
|
||||||
filename := dispParams["filename"]
|
filename := dispParams["filename"]
|
||||||
|
if len(partPath) == 0 {
|
||||||
|
filename = msg.Envelope.Subject + ".eml"
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: set Content-Length if possible
|
// TODO: set Content-Length if possible
|
||||||
|
|
||||||
|
@ -216,8 +221,13 @@ func handleGetPart(ctx *koushin.Context, raw bool) error {
|
||||||
disp := mime.FormatMediaType("attachment", dispParams)
|
disp := mime.FormatMediaType("attachment", dispParams)
|
||||||
ctx.Response().Header().Set("Content-Disposition", disp)
|
ctx.Response().Header().Set("Content-Disposition", disp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(partPath) == 0 {
|
||||||
|
return part.WriteTo(ctx.Response())
|
||||||
|
} else {
|
||||||
return ctx.Stream(http.StatusOK, mimeType, part.Body)
|
return ctx.Stream(http.StatusOK, mimeType, part.Body)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var body string
|
var body string
|
||||||
if strings.HasPrefix(strings.ToLower(mimeType), "text/") {
|
if strings.HasPrefix(strings.ToLower(mimeType), "text/") {
|
||||||
|
|
Loading…
Reference in a new issue