Skip to content

Charset-aware, binary-safe body previews in request/response logging #25

Description

@OmarAlJarrah

Problem

Body previews hardcode UTF-8 (utf8Preview, DefaultInstrumentationStep.kt:323) even though MediaType.charset is parsed and cached (MediaType.kt:53). A latin-1 body logs as mojibake; a gzip/binary body logs as U+FFFD noise.

Proposed change

Add previewText(bytes, mediaType) honouring the declared charset, plus a small isProbablyText heuristic (sample the first N code points) to skip previews for binary bodies. Land it in the shared emitter (see the emitter-extraction issue).

Acceptance

  • Declared charset respected
  • Binary bodies not previewed as text
  • Tests for latin-1 + gzip

Dependencies


Priority: high · Effort: small

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsdk-coresdk-core toolkit

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions