BodyCapture

class BodyCapture(val request: Boolean = true, val response: Boolean = true, val maxBytes: Long = 4 * 1024, val redactHeaders: Set<String> = DEFAULT_REDACTED_HEADERS, val textContentTypes: List<String> = DEFAULT_TEXT_TYPES, val streamingContentTypes: List<String> = DEFAULT_STREAMING_TYPES)(source)

What of a request and response body ends up in a trace.

Off by default, and deliberately so. Bodies are the most sensitive thing the porthole can touch and the most likely to end up pasted into a chat window: an auth response carries tokens, a profile response carries personal data. Turn it on per client, for the client you are actually debugging.

Even when on, capture is bounded three ways: only text-shaped content types, only the first maxBytes, and never a one-shot or duplex body, because reading one would consume the stream the call is about to send.

Constructors

Link copied to clipboard
constructor(request: Boolean = true, response: Boolean = true, maxBytes: Long = 4 * 1024, redactHeaders: Set<String> = DEFAULT_REDACTED_HEADERS, textContentTypes: List<String> = DEFAULT_TEXT_TYPES, streamingContentTypes: List<String> = DEFAULT_STREAMING_TYPES)

Types

Link copied to clipboard
object Companion

The presets, and the two ready-made configurations.

Properties

Link copied to clipboard

Whether this captures anything at all.

Link copied to clipboard

Per body. The rest is dropped and the preview is marked truncated.

Link copied to clipboard

Header names replaced with *, matched case-insensitively.

Link copied to clipboard

Capture request bodies.

Link copied to clipboard

Capture response bodies.

Link copied to clipboard

Content types never read, whatever textContentTypes says, because they have no end. Peeking at a response body blocks until it has the bytes, so peeking at an event stream would hang the call until something happened to be pushed.

Link copied to clipboard

Content-type prefixes worth reading as text. Anything else is skipped.