diff --git a/internal/protocols/httpp/handler_logger.go b/internal/protocols/httpp/handler_logger.go index 0cc6fabd..6ea59e2e 100644 --- a/internal/protocols/httpp/handler_logger.go +++ b/internal/protocols/httpp/handler_logger.go @@ -39,6 +39,7 @@ func dumpRequestLimited(r *http.Request) ([]byte, error) { type responseRecorder struct { w http.ResponseWriter status int + body []byte size int } @@ -50,7 +51,14 @@ func (w *responseRecorder) Write(b []byte) (int, error) { if w.status == 0 { w.status = http.StatusOK } - w.size += len(b) + + contentType := w.Header().Get("Content-Type") + if contentType == "application/sdp" || contentType == "application/trickle-ice-sdpfrag" { + w.body = append(w.body, b...) + } else { + w.size += len(b) + } + return w.w.Write(b) } @@ -64,9 +72,13 @@ func (w *responseRecorder) dump() string { fmt.Fprintf(&buf, "%s %d %s\n", "HTTP/1.1", w.status, http.StatusText(w.status)) w.w.Header().Write(&buf) //nolint:errcheck buf.Write([]byte("\n")) - if w.size > 0 { + + if w.body != nil { + buf.Write(w.body) + } else if w.size > 0 { fmt.Fprintf(&buf, "(body of %d bytes)", w.size) } + return buf.String() } diff --git a/internal/servers/webrtc/http_server.go b/internal/servers/webrtc/http_server.go index cab2a93d..e4695639 100644 --- a/internal/servers/webrtc/http_server.go +++ b/internal/servers/webrtc/http_server.go @@ -247,8 +247,6 @@ func (s *httpServer) onWHIPPost(ctx *gin.Context, pathName string, publish bool) ctx.Header("Location", sessionLocation(publish, pathName, ctx.Request.URL.RawQuery, res.sx.secret)) ctx.Writer.WriteHeader(http.StatusCreated) ctx.Writer.Write(res2.answer) - - res.sx.Log(logger.Debug, "SDP answer:\n"+string(res2.answer)) } func (s *httpServer) onWHIPPatch(ctx *gin.Context, rawSecret string) {