From 6de50dc865063e0679e18531939d8c1f1967f99f Mon Sep 17 00:00:00 2001 From: sentriz Date: Fri, 21 Feb 2020 01:43:27 +0000 Subject: [PATCH] set known mimetypes while streaming --- server/ctrlsubsonic/handlers_raw.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/ctrlsubsonic/handlers_raw.go b/server/ctrlsubsonic/handlers_raw.go index 6c2e651..280473c 100644 --- a/server/ctrlsubsonic/handlers_raw.go +++ b/server/ctrlsubsonic/handlers_raw.go @@ -8,6 +8,7 @@ import ( "github.com/jinzhu/gorm" "senan.xyz/g/gonic/db" + "senan.xyz/g/gonic/mime" "senan.xyz/g/gonic/server/ctrlsubsonic/params" "senan.xyz/g/gonic/server/ctrlsubsonic/spec" ) @@ -65,8 +66,10 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R track.Album.RightPath, track.Filename, ) + if mime, ok := mime.Types[track.Ext()]; ok { + w.Header().Set("Content-Type", mime) + } http.ServeFile(w, r, absPath) - // // after we've served the file, mark the album as played user := r.Context().Value(CtxUser).(*db.User) play := db.Play{