Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playwright/_impl/_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def is_json_content_type(headers: network.HeadersArray = None) -> bool:
if not headers:
return False
for header in headers:
if header["name"] == "Content-Type":
if header["name"].lower() == "content-type":
return header["value"].startswith("application/json")
return False

Expand Down
16 changes: 16 additions & 0 deletions tests/async/test_fetch_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,22 @@ async def test_should_not_double_stringify_body_when_content_type_is_application
await request.dispose()


async def test_should_json_stringify_string_body_when_content_type_is_application_json(
playwright: Playwright, server: Server
) -> None:
request = await playwright.request.new_context()
[req, _] = await asyncio.gather(
server.wait_for_request("/empty.html"),
request.post(
server.EMPTY_PAGE,
headers={"content-type": "application/json"},
data="foo",
),
)
assert req.post_body == b'"foo"'
await request.dispose()


async def test_should_accept_already_serialized_data_as_bytes_when_content_type_is_application_json(
playwright: Playwright, server: Server
) -> None:
Expand Down