File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -341,10 +341,9 @@ async def _marshal_request(
341341 :py:class:`smithy_http.aio.HTTPRequest`"""
342342 headers_list = []
343343 if "host" not in request .fields :
344- host_header = request .destination .host
345- if port := request .destination .port :
346- host_header += f":{ port } "
347- request .fields .set_field (Field (name = "host" , values = [host_header ]))
344+ request .fields .set_field (
345+ Field (name = "host" , values = [request .destination .netloc ])
346+ )
348347
349348 if "accept" not in request .fields :
350349 request .fields .set_field (Field (name = "accept" , values = ["*/*" ]))
Original file line number Diff line number Diff line change @@ -36,18 +36,25 @@ async def test_client_marshal_request() -> None:
3636 assert crt_request .path == "/path?key1=value1&key2=value2" # type: ignore
3737
3838
39- async def test_port_included_in_host_header () -> None :
39+ @pytest .mark .parametrize (
40+ "host,expected" ,
41+ [
42+ ("example.com" , "example.com:8443" ),
43+ ("2001:db8::1" , "[2001:db8::1]:8443" ),
44+ ],
45+ )
46+ async def test_port_included_in_host_header (host : str , expected : str ) -> None :
4047 client = AWSCRTHTTPClient ()
4148 request = HTTPRequest (
4249 method = "GET" ,
4350 destination = URI (
44- host = "example.com" , path = "/path" , query = "key1=value1&key2=value2" , port = 8443
51+ host = host , path = "/path" , query = "key1=value1&key2=value2" , port = 8443
4552 ),
4653 body = BytesIO (),
4754 fields = Fields (),
4855 )
4956 crt_request , _ = await client ._marshal_request (request ) # type: ignore
50- assert crt_request .headers .get ("host" ) == "example.com:8443" # type: ignore
57+ assert crt_request .headers .get ("host" ) == expected # type: ignore
5158
5259
5360def test_stream_write () -> None :
You can’t perform that action at this time.
0 commit comments