Files
mediamtx/internal/protocols/httpp3/server_test.go
T
Alessandro RosandGitHub b5b63d02fc support reading and publishing with Media-over-QUIC (#5815)
Media-over-QUIC is a streaming protocol built upon cutting edge
protocols (QUIC, HTTP3) and browser APIs (WebTransport, WebCodecs).
It's slightly faster than WebRTC, has an advanced data recovery
mechanism (placed at the frame level and not at the packet level), it
supports additional codecs (FLAC) and is less complicated to route.
2026-06-02 23:04:24 +02:00

44 lines
943 B
Go

package httpp3
import (
"crypto/tls"
"io"
"net/http"
"testing"
"github.com/bluenviron/mediamtx/internal/test"
"github.com/quic-go/quic-go/http3"
"github.com/stretchr/testify/require"
)
func TestServer(t *testing.T) {
// test that Server can be initialized and reached by a simple GET request
s := &Server{
Address: "127.0.0.1:18443",
Handler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
}),
Parent: test.NilLogger,
}
err := s.Initialize()
require.NoError(t, err)
defer s.Close()
tr := &http3.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true, //nolint:gosec
},
}
defer tr.Close() //nolint:errcheck
hc := &http.Client{Transport: tr}
res, err := hc.Get("https://127.0.0.1:18443/")
require.NoError(t, err)
defer res.Body.Close()
require.Equal(t, http.StatusOK, res.StatusCode)
_, err = io.ReadAll(res.Body)
require.NoError(t, err)
}