[VarDumper] Fix dumper selection for Accept: */* requests #62805
+20
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this fix?
Fixes incorrect dumper selection when
Accept: */*header is present in HTTP requests, causingdd()anddump()output to disappear in browsers.The Problem
Since version 7.4.0 (PR #58070), when an HTTP request includes
Accept: */*header, the dumper selection logic incorrectly choosesCliDumperinstead ofHtmlDumper. This causes dumps to be sent to STDOUT instead of being rendered in the browser response.Affected scenario:
Common with:
-H "Accept: text/html"Root Cause
Current code only checks if Accept contains literal string
'html':According to RFC 9110 Section 12.5.1,
*/*means "accept any media type", includingtext/html.Solution
Added explicit check for wildcard pattern:
Before:
Accept: */*→ ❌ CliDumper (blank page)After:
Accept: */*→ ✅ HtmlDumper (dump visible)Backward Compatibility
✅ Fully backward compatible - only fixes broken behavior introduced in 7.4.0
Test coverage:
Accept: text/html→ HtmlDumper (unchanged)Accept: */*→ HtmlDumper (fixed)Accept: application/json→ CliDumper (unchanged)