From 4ccb245feb4781459095e465bb4652c50d3bb71e Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Fri, 1 Dec 2023 20:24:00 +0100 Subject: [PATCH] webrtc: fix propagating query parameters when appending slash to paths (#2771) --- internal/core/webrtc_http_server.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/core/webrtc_http_server.go b/internal/core/webrtc_http_server.go index 4a471ae9..035fc22c 100644 --- a/internal/core/webrtc_http_server.go +++ b/internal/core/webrtc_http_server.go @@ -352,7 +352,11 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) { s.onPage(ctx, ctx.Request.URL.Path[1:len(ctx.Request.URL.Path)-len("/publish")], true) case ctx.Request.URL.Path[len(ctx.Request.URL.Path)-1] != '/': - ctx.Writer.Header().Set("Location", ctx.Request.URL.Path[1:]+"/") + l := ctx.Request.URL.Path[1:] + "/" + if ctx.Request.URL.RawQuery != "" { + l += "?" + ctx.Request.URL.RawQuery + } + ctx.Writer.Header().Set("Location", l) ctx.Writer.WriteHeader(http.StatusMovedPermanently) default: