mirror of
https://github.com/Luzifer/tex-api.git
synced 2024-11-09 16:50:03 +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
4
main.go
4
main.go
|
@ -238,11 +238,13 @@ func downloadAssets(res http.ResponseWriter, r *http.Request) {
|
|||
|
||||
var (
|
||||
content io.Reader
|
||||
contentType = "application/zip"
|
||||
filename string
|
||||
)
|
||||
|
||||
switch r.Header.Get("Accept") {
|
||||
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)
|
||||
filename = uid.String() + ".tar"
|
||||
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-Type", "application/octet-stream") // TODO(luzifer): Use a correct type?
|
||||
res.Header().Set("Content-Type", contentType)
|
||||
res.WriteHeader(http.StatusOK)
|
||||
|
||||
io.Copy(res, content)
|
||||
|
|
Loading…
Reference in a new issue