mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-25 12:32:01 -08:00
parent
61d300396d
commit
efcc4c4e65
13 changed files with 200 additions and 105 deletions
45
internal/httpserv/wrapped_server_test.go
Normal file
45
internal/httpserv/wrapped_server_test.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package httpserv
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/bluenviron/mediamtx/internal/logger"
|
||||
)
|
||||
|
||||
type testLogger struct{}
|
||||
|
||||
func (testLogger) Log(_ logger.Level, _ string, _ ...interface{}) {
|
||||
// fmt.Printf(format, args...)
|
||||
}
|
||||
|
||||
func TestFilterEmptyPath(t *testing.T) {
|
||||
s, err := NewWrappedServer(
|
||||
"tcp",
|
||||
"localhost:4555",
|
||||
10*time.Second,
|
||||
"",
|
||||
"",
|
||||
nil,
|
||||
&testLogger{})
|
||||
require.NoError(t, err)
|
||||
defer s.Close()
|
||||
|
||||
conn, err := net.Dial("tcp", "localhost:4555")
|
||||
require.NoError(t, err)
|
||||
defer conn.Close()
|
||||
|
||||
_, err = conn.Write([]byte("OPTIONS http://localhost HTTP/1.1\n" +
|
||||
"Host: localhost:8889\n" +
|
||||
"Accept-Encoding: gzip\n" +
|
||||
"User-Agent: Go-http-client/1.1\n\n"))
|
||||
require.NoError(t, err)
|
||||
|
||||
buf := make([]byte, 20)
|
||||
_, err = io.ReadFull(conn, buf)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue