mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-25 12:32:01 -08:00
hls: reply with 404 to invalid requests
This commit is contained in:
parent
7765de44fc
commit
9486f4f32d
2 changed files with 20 additions and 0 deletions
|
|
@ -217,6 +217,11 @@ outer:
|
|||
|
||||
r.ctxCancel()
|
||||
|
||||
for _, req := range r.requests {
|
||||
req.W.WriteHeader(http.StatusNotFound)
|
||||
req.Res <- nil
|
||||
}
|
||||
|
||||
r.parent.OnRemuxerClose(r)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,27 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestHLSServerNotFound(t *testing.T) {
|
||||
p, ok := newInstance("")
|
||||
require.Equal(t, true, ok)
|
||||
defer p.close()
|
||||
|
||||
req, err := http.NewRequest(http.MethodGet, "http://localhost:8888/stream/", nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err := http.DefaultClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer res.Body.Close()
|
||||
require.Equal(t, http.StatusNotFound, res.StatusCode)
|
||||
}
|
||||
|
||||
func TestHLSServerRead(t *testing.T) {
|
||||
p, ok := newInstance("")
|
||||
require.Equal(t, true, ok)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue