Skip to content

Commit 4ca202b

Browse files
committed
Update CRT HTTP client to include the port in the host for the CRT client if it adds the header
1 parent d9b9e2b commit 4ca202b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ async def _marshal_request(
342342
headers_list = []
343343
if "host" not in request.fields:
344344
request.fields.set_field(
345-
Field(name="host", values=[request.destination.host])
345+
Field(name="host", values=[request.destination.netloc])
346346
)
347347

348348
if "accept" not in request.fields:

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ async def test_client_marshal_request() -> None:
3535
assert crt_request.method == "GET" # type: ignore
3636
assert crt_request.path == "/path?key1=value1&key2=value2" # type: ignore
3737

38+
async def test_port_included_in_host_header() -> None:
39+
client = AWSCRTHTTPClient()
40+
request = HTTPRequest(
41+
method="GET",
42+
destination=URI(
43+
host="example.com", path="/path", query="key1=value1&key2=value2", port=8443
44+
),
45+
body=BytesIO(),
46+
fields=Fields(),
47+
)
48+
crt_request, _ = await client._marshal_request(request) # type: ignore
49+
assert crt_request.headers.get("host") == "example.com:8443" # type: ignore
50+
3851

3952
def test_stream_write() -> None:
4053
stream = BufferableByteStream()

0 commit comments

Comments
 (0)