Skip to content

Commit

Permalink
🐛 Fix: httpx proxy 与 aiohttp timeout 参数新版本修改 (#3152)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu authored Dec 2, 2024
1 parent 6df8d5b commit 9fed938
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
12 changes: 6 additions & 6 deletions envs/pydantic-v1/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions envs/pydantic-v2/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions nonebot/drivers/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ def client(self) -> aiohttp.ClientSession:
@override
async def request(self, setup: Request) -> Response:
if self._params:
params = self._params.copy()
params.update(setup.url.query)
url = setup.url.with_query(params)
url = setup.url.with_query({**self._params, **setup.url.query})
else:
url = setup.url

Expand Down Expand Up @@ -172,11 +170,13 @@ async def websocket(self, setup: Request) -> AsyncGenerator["WebSocket", None]:
else:
raise RuntimeError(f"Unsupported HTTP version: {setup.version}")

timeout = aiohttp.ClientWSTimeout(ws_close=setup.timeout or 10.0) # type: ignore

async with aiohttp.ClientSession(version=version, trust_env=True) as session:
async with session.ws_connect(
setup.url,
method=setup.method,
timeout=setup.timeout or 10, # type: ignore
timeout=timeout,
headers=setup.headers,
proxy=setup.proxy,
) as ws:
Expand Down
4 changes: 3 additions & 1 deletion nonebot/drivers/httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ async def request(self, setup: Request) -> Response:
data=setup.data,
files=setup.files,
json=setup.json,
# ensure the params priority
params=setup.url.raw_query_string,
headers=tuple(setup.headers.items()),
cookies=setup.cookies.jar,
timeout=setup.timeout,
Expand All @@ -102,7 +104,7 @@ async def setup(self) -> None:
headers=self._headers,
cookies=self._cookies.jar,
http2=self._version == HTTPVersion.H2,
proxies=self._proxy,
proxy=self._proxy,
follow_redirects=True,
)
await self._client.__aenter__()
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ loguru = ">=0.6.0,<1.0.0"
python-dotenv = ">=0.21.0,<2.0.0"
typing-extensions = ">=4.4.0,<5.0.0"
tomli = { version = "^2.0.1", python = "<3.11" }
pydantic = ">=1.10.0,<3.0.0,!=2.5.0,!=2.5.1,!=2.10.0"
pydantic = ">=1.10.0,<3.0.0,!=2.5.0,!=2.5.1,!=2.10.0,!=2.10.1"

websockets = { version = ">=10.0", optional = true }
Quart = { version = ">=0.18.0,<1.0.0", optional = true }
fastapi = { version = ">=0.93.0,<1.0.0", optional = true }
aiohttp = { version = "^3.9.0b0", extras = ["speedups"], optional = true }
httpx = { version = ">=0.20.0,<1.0.0", extras = ["http2"], optional = true }
aiohttp = { version = "^3.11.0", extras = ["speedups"], optional = true }
httpx = { version = ">=0.26.0,<1.0.0", extras = ["http2"], optional = true }
uvicorn = { version = ">=0.20.0,<1.0.0", extras = [
"standard",
], optional = true }
Expand Down

0 comments on commit 9fed938

Please sign in to comment.