mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-18 21:07:44 +03:00
Don't send the transcoded file if it is a HEAD request
This commit is contained in:
parent
94f28f6216
commit
36596d4fdb
@ -3,6 +3,7 @@ package subsonic
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -63,10 +64,14 @@ func (c *StreamController) Stream(w http.ResponseWriter, r *http.Request) (*resp
|
||||
w.Header().Set("Content-Length", length)
|
||||
}
|
||||
|
||||
if c, err := io.Copy(w, stream); err != nil {
|
||||
log.Error(ctx, "Error sending transcoded file", "id", id, err)
|
||||
if r.Method == "HEAD" {
|
||||
go func() { _, _ = io.Copy(ioutil.Discard, stream) }()
|
||||
} else {
|
||||
log.Trace(ctx, "Success sending transcode file", "id", id, "size", c)
|
||||
if c, err := io.Copy(w, stream); err != nil {
|
||||
log.Error(ctx, "Error sending transcoded file", "id", id, err)
|
||||
} else {
|
||||
log.Trace(ctx, "Success sending transcode file", "id", id, "size", c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user