Skip to content
Merged
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
8 changes: 6 additions & 2 deletions packages/smithy-http/src/smithy_http/aio/crt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from threading import Lock
from typing import TYPE_CHECKING, Any


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

if "accept" not in request.fields:
request.fields.set_field(Field(name="accept", values=["*/*"]))

for fld in request.fields.entries.values():
# TODO: Use literal values for "header"/"trailer".
if fld.kind.value != FieldPosition.HEADER.value:
Expand Down
1 change: 1 addition & 0 deletions packages/smithy-http/tests/unit/aio/test_crt.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async def test_client_marshal_request() -> None:
)
crt_request = await client._marshal_request(request) # type: ignore
assert crt_request.headers.get("host") == "example.com" # type: ignore
assert crt_request.headers.get("accept") == "*/*" # type: ignore
assert crt_request.method == "GET" # type: ignore
assert crt_request.path == "/path?key1=value1&key2=value2" # type: ignore

Expand Down