aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base')
-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