Repository navigation
fix(apiRequestContext): detect JSON content type with parameters - #43391
Closed
Pushpak Siva Sai (Pushpak731) wants to merge 1 commit into
Closed
Pushpak Siva Sai (Pushpak731) wants to merge 1 commit into
Pushpak Siva Sai (Pushpak731) wants to merge 1 commit into
Conversation
isJsonContentType compared the Content-Type value against 'application/json' exactly, so 'application/json; charset=utf-8' took the raw-string path instead of JSON-serializing string data. Compare the media type only, ignoring parameters and case per RFC 9110. Fixes microsoft#43388
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
APIRequestContextdecided whether to JSON-serialize stringdataby comparing theContent-Typeheader againstapplication/jsonexactly (isJsonContentTypeinpackages/playwright-core/src/client/fetch.ts). A content type with parameters — the very commonapplication/json; charset=utf-8— did not match, so the string was sent raw instead of JSON-serialized.The comparison now uses the media type only, ignoring parameters and case, per RFC 9110 (media types are case-insensitive; parameters do not change the essential type).
Tests in
tests/library/global-fetch.spec.ts:application/json; charset=utf-8is JSON-serialized (hello→"hello"),Application/JSON; charset=utf-8(uppercase media type) is JSON-serialized.Verified locally (
--project=chromium-*): the fullglobal-fetch.spec.tsfile passes (80 tests) with the change; reverting the one-line comparison fails the new parameter and uppercase tests, confirming they exercise the reported path.Fixes #43388