Don't send the transcoded file if it is a HEAD request

This commit is contained in:
Deluan
2020-11-03 16:06:02 -05:00
parent 94f28f6216
commit 36596d4fdb
+5
View File
@@ -3,6 +3,7 @@ package subsonic
import ( import (
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
@@ -63,12 +64,16 @@ func (c *StreamController) Stream(w http.ResponseWriter, r *http.Request) (*resp
w.Header().Set("Content-Length", length) w.Header().Set("Content-Length", length)
} }
if r.Method == "HEAD" {
go func() { _, _ = io.Copy(ioutil.Discard, stream) }()
} else {
if c, err := io.Copy(w, stream); err != nil { if c, err := io.Copy(w, stream); err != nil {
log.Error(ctx, "Error sending transcoded file", "id", id, err) log.Error(ctx, "Error sending transcoded file", "id", id, err)
} else { } else {
log.Trace(ctx, "Success sending transcode file", "id", id, "size", c) log.Trace(ctx, "Success sending transcode file", "id", id, "size", c)
} }
} }
}
return nil, nil return nil, nil
} }