From 8c4587f47779e6fc78644742a838330079d082a5 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 18 Dec 2019 16:57:53 +0100 Subject: Fix header missing from raw e-mail download --- plugins/base/routes.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'plugins') 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 -- cgit v1.2.3