Skip to content

Commit

Permalink
webrtc: include query parameters in session URL (#3920)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Oct 28, 2024
1 parent 1dfb5ba commit 51b21c8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions internal/servers/webrtc/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,21 @@ func writeError(ctx *gin.Context, statusCode int, err error) {
})
}

func sessionLocation(publish bool, path string, secret uuid.UUID) string {
func sessionLocation(publish bool, path string, rawQuery string, secret uuid.UUID) string {
ret := "/" + path + "/"

if publish {
ret += "whip"
} else {
ret += "whep"
}

ret += "/" + secret.String()

if rawQuery != "" {
ret += "?" + rawQuery
}

return ret
}

Expand Down Expand Up @@ -216,7 +223,7 @@ func (s *httpServer) onWHIPPost(ctx *gin.Context, pathName string, publish bool)
ctx.Header("ID", res.sx.uuid.String())
ctx.Header("Accept-Patch", "application/trickle-ice-sdpfrag")
ctx.Writer.Header()["Link"] = whip.LinkHeaderMarshal(servers)
ctx.Header("Location", sessionLocation(publish, pathName, res.sx.secret))
ctx.Header("Location", sessionLocation(publish, pathName, ctx.Request.URL.RawQuery, res.sx.secret))
ctx.Writer.WriteHeader(http.StatusCreated)
ctx.Writer.Write(res.answer)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/servers/webrtc/publish_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@
};

const sendLocalCandidates = (candidates) => {
fetch(sessionUrl + window.location.search, {
fetch(sessionUrl, {
method: 'PATCH',
headers: {
'Content-Type': 'application/trickle-ice-sdpfrag',
Expand Down
2 changes: 1 addition & 1 deletion internal/servers/webrtc/read_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
};

const sendLocalCandidates = (candidates) => {
fetch(sessionUrl + window.location.search, {
fetch(sessionUrl, {
method: 'PATCH',
headers: {
'Content-Type': 'application/trickle-ice-sdpfrag',
Expand Down

0 comments on commit 51b21c8

Please sign in to comment.