Repository navigation
fix(fetch): send empty form and multipart bodies - #3239
Merged
Merged
Conversation
`form={}` and `multipart={}` were ignored because empty dicts are falsy,
so the request went out without a body or Content-Type. Check for None
instead, like `data`, and match the Node client: an empty form is sent as
application/x-www-form-urlencoded and an empty multipart as an empty
multipart/form-data body.
Fixes: microsoft/playwright#43286
Pavel Feldman (pavelfeldman)
marked this pull request as ready for review
October 12, 2026 17:35
Dmitry Gozman (dgozman)
approved these changes
Oct 12, 2026
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.
APIRequestContextcheckedformandmultipartfor truthiness, soform={}andmultipart={}were skipped and the request went out with no body and noContent-Type. In the Node client{}is truthy, so it sendsapplication/x-www-form-urlencodedfor an empty form and an emptymultipart/form-databody for an empty multipart.This checks them for
None, likedata, and sends an empty form field list forform={}, sinceobject_to_array({})returnsNone. The requests are now byte-for-byte what the Node client sends.Tests: an empty form and an empty multipart reach the server with the right
Content-Type(async and sync). The multipart test uses PUT because the Twisted test server rejects an empty multipart POST body before handling it. Both fail without the fix and pass on chromium, firefox and webkit.Fixes: microsoft/playwright#43286