Browse Source

Fix header missing from raw e-mail download

master
Simon Ser 4 years ago
parent
commit
8c4587f477
No known key found for this signature in database GPG Key ID: FDE7BE0E88F5E48
1 changed files with 11 additions and 1 deletions
  1. +11
    -1
      plugins/base/routes.go

+ 11
- 1
plugins/base/routes.go View File

@@ -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


Loading…
Cancel
Save