1
0
Fork 0
mirror of https://github.com/Luzifer/tex-api.git synced 2024-11-09 08:40:02 +00:00

Deliver correct content-type

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-09-17 11:14:49 +02:00
parent a9410c6f8b
commit 71096bbac5
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -237,12 +237,14 @@ func downloadAssets(res http.ResponseWriter, r *http.Request) {
} }
var ( var (
content io.Reader content io.Reader
filename string contentType = "application/zip"
filename string
) )
switch r.Header.Get("Accept") { switch r.Header.Get("Accept") {
case "application/tar", "application/x-tar", "applicaton/x-gtar", "multipart/x-tar", "application/x-compress", "application/x-compressed": case "application/tar", "application/x-tar", "applicaton/x-gtar", "multipart/x-tar", "application/x-compress", "application/x-compressed":
contentType = "application/tar"
content, err = buildAssetsTAR(uid) content, err = buildAssetsTAR(uid)
filename = uid.String() + ".tar" filename = uid.String() + ".tar"
default: default:
@ -256,7 +258,7 @@ func downloadAssets(res http.ResponseWriter, r *http.Request) {
} }
res.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%q", filename)) res.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%q", filename))
res.Header().Set("Content-Type", "application/octet-stream") // TODO(luzifer): Use a correct type? res.Header().Set("Content-Type", contentType)
res.WriteHeader(http.StatusOK) res.WriteHeader(http.StatusOK)
io.Copy(res, content) io.Copy(res, content)