Browse Source

Merge c7497bb22f into 50322fc14e

pull/3195/merge
neilyoung 2 years ago committed by GitHub
parent
commit
d27a8a99b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      internal/servers/webrtc/http_server.go

14
internal/servers/webrtc/http_server.go

@ -158,8 +158,8 @@ func (s *httpServer) onWHIPOptions(ctx *gin.Context, path string, publish bool)
} }
ctx.Writer.Header().Set("Access-Control-Allow-Methods", "OPTIONS, GET, POST, PATCH, DELETE") ctx.Writer.Header().Set("Access-Control-Allow-Methods", "OPTIONS, GET, POST, PATCH, DELETE")
ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, If-Match") ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, If-Match, Access-Control-Allow-Methods, ETag")
ctx.Writer.Header().Set("Access-Control-Expose-Headers", "Link") ctx.Writer.Header().Set("Access-Control-Expose-Headers", "Link, Access-Control-Allow-Methods, ETag")
ctx.Writer.Header()["Link"] = webrtc.LinkHeaderMarshal(servers) ctx.Writer.Header()["Link"] = webrtc.LinkHeaderMarshal(servers)
ctx.Writer.WriteHeader(http.StatusNoContent) ctx.Writer.WriteHeader(http.StatusNoContent)
} }
@ -198,12 +198,16 @@ func (s *httpServer) onWHIPPost(ctx *gin.Context, path string, publish bool) {
} }
ctx.Writer.Header().Set("Content-Type", "application/sdp") ctx.Writer.Header().Set("Content-Type", "application/sdp")
ctx.Writer.Header().Set("Access-Control-Expose-Headers", "ETag, ID, Accept-Patch, Link, Location") ctx.Writer.Header().Set("Access-Control-Expose-Headers", "ETag, ID, Accept-Patch, Link, Location, Access-Control-Allow-Methods")
ctx.Writer.Header().Set("ETag", "*") ctx.Writer.Header().Set("ETag", "*")
ctx.Writer.Header().Set("ID", res.sx.uuid.String()) ctx.Writer.Header().Set("ID", res.sx.uuid.String())
ctx.Writer.Header().Set("Accept-Patch", "application/trickle-ice-sdpfrag") ctx.Writer.Header().Set("Accept-Patch", "application/trickle-ice-sdpfrag")
ctx.Writer.Header()["Link"] = webrtc.LinkHeaderMarshal(servers) ctx.Writer.Header()["Link"] = webrtc.LinkHeaderMarshal(servers)
ctx.Writer.Header().Set("Location", sessionLocation(publish, res.sx.secret)) scheme := ctx.Request.URL.Scheme
if scheme == "" {
scheme = "http"
}
ctx.Writer.Header().Set("Location", scheme + "://" + ctx.Request.Host + ctx.Request.URL.Path + "/" + res.sx.secret.String())
ctx.Writer.WriteHeader(http.StatusCreated) ctx.Writer.WriteHeader(http.StatusCreated)
ctx.Writer.Write(res.answer) ctx.Writer.Write(res.answer)
} }
@ -285,7 +289,7 @@ func (s *httpServer) onRequest(ctx *gin.Context) {
if ctx.Request.Method == http.MethodOptions && if ctx.Request.Method == http.MethodOptions &&
ctx.Request.Header.Get("Access-Control-Request-Method") != "" { ctx.Request.Header.Get("Access-Control-Request-Method") != "" {
ctx.Writer.Header().Set("Access-Control-Allow-Methods", "OPTIONS, GET, POST, PATCH, DELETE") ctx.Writer.Header().Set("Access-Control-Allow-Methods", "OPTIONS, GET, POST, PATCH, DELETE")
ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, If-Match") ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, If-Match, Access-Control-Allow-Methods, ETag")
ctx.Writer.WriteHeader(http.StatusNoContent) ctx.Writer.WriteHeader(http.StatusNoContent)
return return
} }

Loading…
Cancel
Save