Skip to content

Commit 5313ac2

Browse files
fix(network): keep blank values in Request.post_data_json for form bodies (#3248)
1 parent 9d8c50f commit 5313ac2

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎playwright/_impl/_network.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def post_data_json(self) -> Optional[Any]:
261261
return None
262262
content_type = self.headers.get("content-type")
263263
if content_type and "application/x-www-form-urlencoded" in content_type:
264-
return dict(parse.parse_qsl(post_data))
264+
return dict(parse.parse_qsl(post_data, keep_blank_values=True))
265265
try:
266266
return json.loads(post_data)
267267
except Exception:

‎tests/async/test_page_network_request.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ async def test_should_parse_the_data_if_content_type_is_application_x_www_form_u
5555
headers: {
5656
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
5757
},
58-
body: 'foo=bar&baz=123'
58+
body: 'foo=bar&baz=123&empty='
5959
})"""
6060
)
6161
request = await request_info.value
6262
assert request
63-
assert request.post_data_json == {"foo": "bar", "baz": "123"}
63+
assert request.post_data_json == {"foo": "bar", "baz": "123", "empty": ""}
6464

6565

6666
async def test_existing_response_should_return_response_after_it_is_received(

0 commit comments

Comments
 (0)