Skip to content

Commit ca05f6d

Browse files
committed
Add accept header when unset to crt request
1 parent 94e9f57 commit ca05f6d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/smithy-http/src/smithy_http/aio/crt.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from threading import Lock
1212
from typing import TYPE_CHECKING, Any
1313

14+
1415
if TYPE_CHECKING:
1516
# pyright doesn't like optional imports. This is reasonable because if we use these
1617
# in type hints then they'd result in runtime errors.
@@ -292,11 +293,14 @@ async def _marshal_request(
292293
"""Create :py:class:`awscrt.http.HttpRequest` from
293294
:py:class:`smithy_http.aio.HTTPRequest`"""
294295
headers_list = []
295-
if "Host" not in request.fields:
296+
if "host" not in request.fields:
296297
request.fields.set_field(
297-
Field(name="Host", values=[request.destination.host])
298+
Field(name="host", values=[request.destination.host])
298299
)
299300

301+
if "accept" not in request.fields:
302+
request.fields.set_field(Field(name="accept", values=["*/*"]))
303+
300304
for fld in request.fields.entries.values():
301305
# TODO: Use literal values for "header"/"trailer".
302306
if fld.kind.value != FieldPosition.HEADER.value:

packages/smithy-http/tests/unit/aio/test_crt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ async def test_client_marshal_request() -> None:
2828
)
2929
crt_request = await client._marshal_request(request) # type: ignore
3030
assert crt_request.headers.get("host") == "example.com" # type: ignore
31+
assert crt_request.headers.get("accept") == "*/*" # type: ignore
3132
assert crt_request.method == "GET" # type: ignore
3233
assert crt_request.path == "/path?key1=value1&key2=value2" # type: ignore
3334

0 commit comments

Comments
 (0)