From 4ef644be2480a39511048d86fcb1cb875932cfbf Mon Sep 17 00:00:00 2001 From: yourok <8yourok8@mail.ru> Date: Sat, 22 Dec 2018 14:33:16 +0300 Subject: [PATCH] fix m3u headers --- src/server/web/Torrent.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/server/web/Torrent.go b/src/server/web/Torrent.go index 6e2b1bd..049edc2 100644 --- a/src/server/web/Torrent.go +++ b/src/server/web/Torrent.go @@ -446,6 +446,7 @@ func torrentPlayListAll(c echo.Context) error { m3u := helpers.MakeM3ULists(list, c.Scheme()+"://"+c.Request().Host) c.Response().Header().Set("Content-Type", "audio/x-mpegurl") + c.Response().Header().Set("Connection", "close") c.Response().Header().Set("Content-Disposition", `attachment; filename="playlist.m3u"`) http.ServeContent(c.Response(), c.Request(), "playlist.m3u", time.Now(), bytes.NewReader([]byte(m3u))) return c.NoContent(http.StatusOK) @@ -513,7 +514,7 @@ func torrentPlay(c echo.Context) error { name := utils.CleanFName(tor.Name()) + ".m3u" c.Response().Header().Set("ETag", httptoo.EncodeQuotedString(fmt.Sprintf("%s/%s", tor.Hash().HexString(), name))) c.Response().Header().Set("Content-Disposition", `attachment; filename="`+name+`"`) - http.ServeContent(c.Response(), c.Request(), name, time.Time{}, bytes.NewReader([]byte(m3u))) + http.ServeContent(c.Response(), c.Request(), name, time.Now(), bytes.NewReader([]byte(m3u))) return c.NoContent(http.StatusOK) } @@ -535,7 +536,7 @@ func torrentPlay(c echo.Context) error { fileInd, _ := strconv.Atoi(qfile) file := helpers.FindFile(fileInd, tor) if file == nil { - return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprint("File", files[fileInd], "not found in torrent", tor.Name())) + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprint("File index ", fileInd, " not found in torrent ", tor.Name())) } return bts.Play(tor, file, preload, c) }