Skip to content

Commit 83d1146

Browse files
committed
updated
1 parent 2277aad commit 83d1146

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

aiohttp/web_response.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,6 @@ def __init__(
600600
real_headers[hdrs.CONTENT_TYPE] = content_type + "; charset=" + charset
601601
body = text.encode(charset)
602602
text = None
603-
elif hdrs.CONTENT_TYPE in real_headers:
604-
if content_type is not None or charset is not None:
605-
raise ValueError(
606-
"passing both Content-Type header and "
607-
"content_type or charset params "
608-
"is forbidden"
609-
)
610603
elif content_type is not None:
611604
if charset is not None:
612605
content_type += "; charset=" + charset

tests/test_web_response.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,16 +1152,19 @@ def test_ctor_both_charset_param_and_header_with_text() -> None:
11521152
)
11531153

11541154

1155-
def test_ctor_both_content_type_param_and_header() -> None:
1156-
with pytest.raises(ValueError):
1157-
web.Response(
1158-
headers={"Content-Type": "application/json"}, content_type="text/html"
1159-
)
1155+
def test_ctor_content_type_param_and_header_without_text() -> None:
1156+
resp = web.Response(
1157+
headers={"Content-Type": "application/json"}, content_type="text/html"
1158+
)
11601159

1160+
assert resp.content_type == "text/html"
11611161

1162-
def test_ctor_both_charset_param_and_header() -> None:
1163-
with pytest.raises(ValueError):
1164-
web.Response(headers={"Content-Type": "application/json"}, charset="koi8-r")
1162+
1163+
def test_ctor_charset_param_and_header_without_text() -> None:
1164+
resp = web.Response(headers={"Content-Type": "application/json"}, charset="koi8-r")
1165+
1166+
assert resp.content_type == "application/json"
1167+
assert resp.charset is None
11651168

11661169

11671170
async def test_assign_nonbyteish_body() -> None:

0 commit comments

Comments
 (0)