Skip to content

Commit c4c99ac

Browse files
authored
Fix encoding of path in aiohttp requests (#461)
1 parent 13c54ed commit c4c99ac

File tree

1 file changed

+13
-4
lines changed
  • packages/smithy-http/src/smithy_http/aio

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
from copy import copy, deepcopy
44
from itertools import chain
55
from typing import TYPE_CHECKING, Any
6-
from urllib.parse import parse_qs, urlunparse
6+
from urllib.parse import parse_qs
7+
8+
import yarl
79

810
if TYPE_CHECKING:
911
# pyright doesn't like optional imports. This is reasonable because if we use these
@@ -97,10 +99,17 @@ async def send(
9799
) as resp:
98100
return await self._marshal_response(resp)
99101

100-
def _serialize_uri_without_query(self, uri: URI) -> str:
102+
def _serialize_uri_without_query(self, uri: URI) -> yarl.URL:
101103
"""Serialize all parts of the URI up to and including the path."""
102-
components = (uri.scheme, uri.netloc, uri.path or "", "", "", "")
103-
return urlunparse(components)
104+
return yarl.URL.build(
105+
scheme=uri.scheme or "",
106+
host=uri.host,
107+
port=uri.port,
108+
user=uri.username,
109+
password=uri.password,
110+
path=uri.path or "",
111+
encoded=True,
112+
)
104113

105114
async def _marshal_response(
106115
self, aiohttp_resp: "aiohttp.ClientResponse"

0 commit comments

Comments
 (0)