webrtc, hls: reply status code 204 to OPTIONS requests (#2141)

This commit is contained in:
Alessandro Ros 2023-08-02 20:52:26 +02:00 committed by GitHub
parent 42f9bacefb
commit ef8b9fb63d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -101,7 +101,7 @@ func (s *hlsHTTPServer) onRequest(ctx *gin.Context) {
case http.MethodOptions:
ctx.Writer.Header().Set("Access-Control-Allow-Methods", "OPTIONS, GET")
ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Range")
ctx.Writer.WriteHeader(http.StatusOK)
ctx.Writer.WriteHeader(http.StatusNoContent)
return
case http.MethodGet:

View file

@ -246,7 +246,7 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) {
case http.MethodOptions:
ctx.Writer.Header().Set("Access-Control-Allow-Methods", "OPTIONS, GET, POST, PATCH")
ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, If-Match")
ctx.Writer.WriteHeader(http.StatusOK)
ctx.Writer.WriteHeader(http.StatusNoContent)
return
case http.MethodGet:
@ -359,7 +359,7 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) {
ctx.Writer.Header().Set("Access-Control-Allow-Methods", "OPTIONS, GET, POST, PATCH")
ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, If-Match")
ctx.Writer.Header()["Link"] = iceServersToLinkHeader(servers)
ctx.Writer.WriteHeader(http.StatusOK)
ctx.Writer.WriteHeader(http.StatusNoContent)
case http.MethodPost:
if ctx.Request.Header.Get("Content-Type") != "application/sdp" {

View file

@ -29,7 +29,7 @@ func whipGetICEServers(
require.NoError(t, err)
defer res.Body.Close()
require.Equal(t, http.StatusOK, res.StatusCode)
require.Equal(t, http.StatusNoContent, res.StatusCode)
link, ok := res.Header["Link"]
require.Equal(t, true, ok)
@ -464,7 +464,7 @@ func TestWebRTCPublish(t *testing.T) {
require.NoError(t, err)
defer res.Body.Close()
require.Equal(t, http.StatusOK, res.StatusCode)
require.Equal(t, http.StatusNoContent, res.StatusCode)
if auth != "none" {
_, ok := res.Header["Link"]