Skip to content

Commit

Permalink
fix: network using aiohttp
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo2011 committed Jan 14, 2024
1 parent e1b379c commit 14ce200
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bilibili_api/utils/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,18 @@ async def request(self, raw: bool = False, **kwargs) -> Union[int, str, dict]:
# 判断http_client的类型
if settings.http_client == settings.HTTPClient.HTTPX:
session = get_session()
resp = await session.request(**config)
real_data = self._process_response(
resp, await self._get_resp_text(resp), raw=raw
)
return real_data
elif settings.http_client == settings.HTTPClient.AIOHTTP:
session = get_aiohttp_session()
resp = await session.request(**config)
real_data = self._process_response(
resp, await self._get_resp_text(resp), raw=raw
)
return real_data
async with session.request(**config) as resp:
real_data = self._process_response(
resp, await self._get_resp_text(resp), raw=raw
)
return real_data

def _process_response(
self,
Expand Down

0 comments on commit 14ce200

Please sign in to comment.