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:
parent
a9410c6f8b
commit
71096bbac5
1 changed files with 5 additions and 3 deletions
8
main.go
8
main.go
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue