Browse Source

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

pull/2143/head
Alessandro Ros 2 years ago committed by GitHub
parent
commit
ef8b9fb63d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      internal/core/hls_http_server.go
  2. 4
      internal/core/webrtc_http_server.go
  3. 4
      internal/core/webrtc_manager_test.go

2
internal/core/hls_http_server.go

@ -101,7 +101,7 @@ func (s *hlsHTTPServer) onRequest(ctx *gin.Context) { @@ -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:

4
internal/core/webrtc_http_server.go

@ -246,7 +246,7 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) { @@ -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) { @@ -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" {

4
internal/core/webrtc_manager_test.go

@ -29,7 +29,7 @@ func whipGetICEServers( @@ -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) { @@ -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"]

Loading…
Cancel
Save