HttpBodyCapture class

Keeps a bounded preview of an HTTP body for the HTTP record.

Only the first limit bytes are kept, however large the body is. The rendered text is cut so that, once JSON-escaped by the native bridge, it stays within limit characters: two bodies plus headers then fit the native record limit (MAX_LOG_SIZE_BYTES * 2, 256K characters), so the record and its client span are always stored.

Constructors

HttpBodyCapture({int limit = defaultLimit})

Properties

hashCode → int
The hash code for this object.
no setterinherited
isEmpty → bool
no setter
isTruncated → bool
no setter
keptBytes → int
Bytes held in memory for the preview (never more than limit).
no setter
limit → int
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
totalBytes → int
Bytes seen so far, including the ones not kept in the preview.
no setter

Methods

add(List<int> chunk) → void
addText(String text) → void
Adds text written with write. Only the part that can still fit the preview is UTF-8 encoded, so a huge string is never copied.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
render() → String?
Text for the record: pretty-printed JSON when the whole body is valid JSON and the result fits, otherwise the (cut) text, or a placeholder for bodies that are not UTF-8 text.
skipContent() → void
Stops keeping content: only the size is recorded (binary bodies).
skipContentIfBinary(String? mimeType) → void
Skips the content when mimeType is a binary type.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

escapedLength(String text) → int
Length of text once escaped into a JSON string by Android's JSONObject or iOS JSONSerialization (both escape / too).
fitToLimit(String text, int limit, {bool truncated = false}) → String
Cuts text so its JSON-escaped length is at most limit and appends truncatedSuffix when anything was left out.
isBinaryContentType(String? mimeType) → bool
Media types whose body is never text: images, audio, video, fonts, archives, protobuf/gRPC and generic binary. +json/+xml types (such as image/svg+xml) stay text.

Constants

defaultLimit → const int
Same default as the native OkHttp / URLSession capture (64 KB).
truncatedSuffix → const String
Same marker the native SDKs append to a cut body.