diff --git a/docs/4-read/10-vlc.md b/docs/4-read/10-vlc.md index eca44d3b..2d5b0543 100644 --- a/docs/4-read/10-vlc.md +++ b/docs/4-read/10-vlc.md @@ -21,7 +21,7 @@ The VLC shipped with Ubuntu 21.10 doesn't support playing RTSP due to a license ```sh sudo apt purge -y vlc -snap install vlc +sudo snap install vlc ``` ### Encrypted RTSP diff --git a/internal/protocols/httpp/handler_logger.go b/internal/protocols/httpp/handler_logger.go index 7f92ec7b..6cc4b97b 100644 --- a/internal/protocols/httpp/handler_logger.go +++ b/internal/protocols/httpp/handler_logger.go @@ -11,7 +11,7 @@ import ( ) const ( - maxDumpedRequestBodySize = 10 * 1024 + maxRequestBodySizeToLog = 10 * 1024 ) var requestHeadersToRedact = map[string]struct{}{ @@ -23,6 +23,11 @@ var requestHeadersToRedact = map[string]struct{}{ "X-Auth-Token": {}, } +var requestBodyContentTypeToLog = map[string]struct{}{ + "application/sdp": {}, + "application/trickle-ice-sdpfrag": {}, +} + func cloneRequestForLogging(r *http.Request) *http.Request { clone := r.Clone(r.Context()) clone.Header = r.Header.Clone() @@ -37,15 +42,15 @@ func cloneRequestForLogging(r *http.Request) *http.Request { } func dumpRequestLimited(r *http.Request) ([]byte, error) { - peek, err := io.ReadAll(io.LimitReader(r.Body, maxDumpedRequestBodySize+1)) + peek, err := io.ReadAll(io.LimitReader(r.Body, maxRequestBodySizeToLog+1)) if err != nil { return nil, err } capped := peek - if int64(len(capped)) > maxDumpedRequestBodySize { - capped = append([]byte(nil), capped[:maxDumpedRequestBodySize]...) - capped = append(capped, []byte("\n\n(body truncated)\n")...) + if int64(len(capped)) > maxRequestBodySizeToLog { + capped = append([]byte(nil), capped[:maxRequestBodySizeToLog]...) + capped = append(capped, []byte("\n\n(truncated body)\n")...) } original := r.Body @@ -76,7 +81,7 @@ func (w *responseRecorder) Write(b []byte) (int, error) { } contentType := w.Header().Get("Content-Type") - if contentType == "application/sdp" || contentType == "application/trickle-ice-sdpfrag" { + if _, ok := requestBodyContentTypeToLog[contentType]; ok { w.body = append(w.body, b...) } else { w.size += len(b)