Skip to content

fix(printer): preserve JSON and HTML response content - #40

Open
rupayon123 wants to merge 7 commits into
kavix:mainfrom
rupayon123:contribution/json-printer-correctness-20260913
Open

rupayon123 wants to merge 7 commits into
kavix:mainfrom
rupayon123:contribution/json-printer-correctness-20260913

Conversation

@rupayon123

@rupayon123 rupayon123 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Problem and change

Preserve JSON and HTML response content during formatting. JSON keys and string values are escaped correctly, actual written byte counts include partial writes, and trailing documents/junk/read errors are reported rather than silently ignored. HTML formatting preserves script/style raw text, namespace-qualified attributes, and preformatted whitespace, including a leading newline.

Response selection now parses the media type itself: structured +json and XHTML bodies reach their formatters instead of being hidden as binary data, and a MIME parameter cannot accidentally select the JSON or HTML formatter.

Validation

Focused regressions reproduced every original failure. Full env -u NO_COLOR go test ./..., go vet ./..., builds, formatting and git diff --check pass. Regression cases include JSON round trips and failing writers/readers, HTML parse-format-parse content comparisons, namespaced attributes, and response media-type dispatch. Color environment isolation is submitted separately in PR39. golangci-lint was not run locally.

Prepared with AI assistance. Remote CI is verified separately on the latest head; passing checks do not imply maintainer approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant