Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add keyword argument encode_url for ClientSession._request #8466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ def request(
"""Perform HTTP request."""
return _RequestContextManager(self._request(method, url, **kwargs))

def _build_url(self, str_or_url: StrOrURL) -> URL:
url = URL(str_or_url)
def _build_url(self, str_or_url: StrOrURL, **kwargs: Any) -> URL:
url = URL(str_or_url, encoded=kwargs.get("encode_url"))
if self._base_url is None:
return url
else:
Expand Down Expand Up @@ -385,6 +385,7 @@ async def _request(
auto_decompress: Optional[bool] = None,
max_line_size: Optional[int] = None,
max_field_size: Optional[int] = None,
encode_url: Optional[bool] = False,
) -> ClientResponse:
# NOTE: timeout clamps existing connect and read timeouts. We cannot
# set the default to None because we need to detect if the user wants
Expand Down Expand Up @@ -416,7 +417,7 @@ async def _request(
proxy_headers = self._prepare_headers(proxy_headers)

try:
url = self._build_url(str_or_url)
url = self._build_url(str_or_url, encode_url=encode_url)
except ValueError as e:
raise InvalidUrlClientError(str_or_url) from e

Expand Down
Loading