Skip to content

fix: show HAL+JSON responses correctly in Telescope#85

Open
emanueljacob wants to merge 1 commit into
saloonphp:v4from
emanueljacob:fix/telescope-hal-json-responses
Open

fix: show HAL+JSON responses correctly in Telescope#85
emanueljacob wants to merge 1 commit into
saloonphp:v4from
emanueljacob:fix/telescope-hal-json-responses

Conversation

@emanueljacob

Copy link
Copy Markdown

Why

Telescope entries for Saloon client requests only decode bodies when the content type contains application/json.

APIs that return application/hal+json (or other +json types) never match that check. The body stays a string, and sanitizeResponseBody() falls through to HTML Response, so the real payload is missing in Telescope.

What changed

  • Treat +json content types (for example application/hal+json, application/vnd.api+json) as JSON in formatBody()
  • Decode JSON object/array bodies in sanitizeResponseBody() the same way Telescope's ClientRequestWatcher does, even when the content type is not exact application/json
  • Add Pest coverage for hal+json, charset variants, JSON:API, redaction, and the HTML negative case

HTML and other non-JSON bodies still show as HTML Response.

Responses with content types like application/hal+json were stored
as "HTML Response" because only application/json was decoded.
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