add dlna header

This commit is contained in:
YouROK
2021-09-08 11:39:50 +03:00
parent 209e38b7e3
commit 31f50556ec

View File

@@ -8,6 +8,7 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/anacrolix/dms/dlna"
"github.com/anacrolix/missinggo/httptoo" "github.com/anacrolix/missinggo/httptoo"
"github.com/anacrolix/torrent" "github.com/anacrolix/torrent"
@@ -60,6 +61,14 @@ func (t *Torrent) Stream(fileID int, req *http.Request, resp http.ResponseWriter
resp.Header().Set("Connection", "close") resp.Header().Set("Connection", "close")
resp.Header().Set("ETag", httptoo.EncodeQuotedString(fmt.Sprintf("%s/%s", t.Hash().HexString(), file.Path()))) resp.Header().Set("ETag", httptoo.EncodeQuotedString(fmt.Sprintf("%s/%s", t.Hash().HexString(), file.Path())))
resp.Header().Set("transferMode.dlna.org", "Streaming")
if req.Header.Get("getContentFeatures.dlna.org") != "" {
resp.Header().Set("contentFeatures.dlna.org", dlna.ContentFeatures{
SupportRange: true,
SupportTimeSeek: true,
}.String())
}
http.ServeContent(resp, req, file.Path(), time.Unix(t.Timestamp, 0), reader) http.ServeContent(resp, req, file.Path(), time.Unix(t.Timestamp, 0), reader)