Skip to content

Commit 99d1053

Browse files
committed
Fix: user/password replacement is not allowed for relative urls
fix error `user/password replacement is not allowed for relative URLs` when using the parameter base_url of ClientSession constructor to send aiohttp requests
1 parent 28602ae commit 99d1053

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

skywalking/plugins/sw_aiohttp.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,16 @@ def install():
3939

4040
_request = ClientSession._request
4141

42+
def _build_url(client_session: ClientSession, str_or_url):
43+
url = URL(str_or_url)
44+
if client_session._base_url is None:
45+
return url
46+
else:
47+
assert not url.is_absolute() and url.path.startswith('/')
48+
return client_session._base_url.join(url)
49+
4250
async def _sw_request(self: ClientSession, method: str, str_or_url, **kwargs):
43-
url = URL(str_or_url).with_user(None).with_password(None)
51+
url = _build_url(self, str_or_url).with_user(None).with_password(None)
4452
peer = f"{url.host or ''}:{url.port or ''}"
4553

4654
if config.agent_protocol == 'http' and config.agent_collector_backend_services.rstrip('/') \

0 commit comments

Comments
 (0)