Merge branch 'master' into new-torrent

This commit is contained in:
nikk gitanes
2021-09-14 01:19:28 +03:00
9 changed files with 50 additions and 242 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/anacrolix/missinggo/httptoo"
"github.com/anacrolix/torrent"
mt "server/mimetype"
sets "server/settings"
"server/torr/state"
)
@@ -61,8 +62,12 @@ func (t *Torrent) Stream(fileID int, req *http.Request, resp http.ResponseWriter
resp.Header().Set("Connection", "close")
resp.Header().Set("ETag", httptoo.EncodeQuotedString(fmt.Sprintf("%s/%s", t.Hash().HexString(), file.Path())))
// DLNA headers
resp.Header().Set("transferMode.dlna.org", "Streaming")
mime, err := mt.MimeTypeByPath(file.Path())
if err == nil && mime.IsMedia() {
resp.Header().Set("content-type", mime.String())
}
if req.Header.Get("getContentFeatures.dlna.org") != "" {
resp.Header().Set("contentFeatures.dlna.org", dlna.ContentFeatures{
SupportRange: true,