aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2019-12-18 16:57:53 +0100
committerSimon Ser <contact@emersion.fr>2019-12-18 16:57:53 +0100
commit8c4587f47779e6fc78644742a838330079d082a5 (patch)
treeb09a0c7f00bdd5194e0e55c2928559d25288e2b4 /plugins
parent3d2da43207ee963cb813dfba3a338b9d9c918319 (diff)
downloadalps-8c4587f47779e6fc78644742a838330079d082a5.tar.gz
alps-8c4587f47779e6fc78644742a838330079d082a5.zip
Fix header missing from raw e-mail download
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/routes.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/plugins/base/routes.go b/plugins/base/routes.go
index c7b6609..e83c047 100644
--- a/plugins/base/routes.go
+++ b/plugins/base/routes.go
@@ -203,8 +203,13 @@ func handleGetPart(ctx *koushin.Context, raw bool) error {
}
if raw {
+ ctx.Response().Header().Set("Content-Type", mimeType)
+
disp, dispParams, _ := part.Header.ContentDisposition()
filename := dispParams["filename"]
+ if len(partPath) == 0 {
+ filename = msg.Envelope.Subject + ".eml"
+ }
// TODO: set Content-Length if possible
@@ -216,7 +221,12 @@ func handleGetPart(ctx *koushin.Context, raw bool) error {
disp := mime.FormatMediaType("attachment", dispParams)
ctx.Response().Header().Set("Content-Disposition", disp)
}
- return ctx.Stream(http.StatusOK, mimeType, part.Body)
+
+ if len(partPath) == 0 {
+ return part.WriteTo(ctx.Response())
+ } else {
+ return ctx.Stream(http.StatusOK, mimeType, part.Body)
+ }
}
var body string