Avoid rebuilding urls for every request (#715)

* Avoid rebuilding urls for every request

* more fixes

* more fixes

* make mypy happy

* reduce

* tweak

* fix tests

* fix tests

* tweak

* tweak

* lint

* fix type
This commit is contained in:
J. Nick Koston
2024-01-29 05:26:00 -10:00
committed by GitHub
parent 69dcc0d8bb
commit b479b6d84d
7 changed files with 73 additions and 62 deletions

View File

@@ -3,6 +3,7 @@ import asyncio
from typing import Any, Dict, Optional, Tuple, Union
import aiohttp
from yarl import URL
from .deviceconfig import DeviceConfig
from .exceptions import (
@@ -25,7 +26,7 @@ class HttpClient:
self._config = config
self._client_session: aiohttp.ClientSession = None
self._jar = aiohttp.CookieJar(unsafe=True, quote_cookie=False)
self._last_url = f"http://{self._config.host}/"
self._last_url = URL(f"http://{self._config.host}/")
@property
def client(self) -> aiohttp.ClientSession:
@@ -41,7 +42,7 @@ class HttpClient:
async def post(
self,
url: str,
url: URL,
*,
params: Optional[Dict[str, Any]] = None,
data: Optional[bytes] = None,