mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-02 09:26:12 +08:00
19 lines
492 B
Python
19 lines
492 B
Python
import httpx
|
|
|
|
from nonebot_bison.plugin_config import plugin_config
|
|
|
|
http_args = {
|
|
"proxy": plugin_config.bison_proxy or None,
|
|
}
|
|
http_headers = {"user-agent": plugin_config.bison_ua}
|
|
|
|
|
|
def http_client(*args, **kwargs):
|
|
if headers := kwargs.get("headers"):
|
|
new_headers = http_headers.copy()
|
|
new_headers.update(headers)
|
|
kwargs["headers"] = new_headers
|
|
else:
|
|
kwargs["headers"] = http_headers
|
|
return httpx.AsyncClient(*args, **kwargs, **http_args)
|