add content-type o http headers

This commit is contained in:
nikk gitanes
2021-09-13 17:12:19 +03:00
parent 1860d25e88
commit c27feb668c
2 changed files with 7 additions and 2 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,