Fix messed up parameters in request

This commit is contained in:
Andre Basche 2023-06-28 20:25:52 +02:00
parent 52837f16e3
commit b5d8a90d79
5 changed files with 20 additions and 11 deletions

View file

@ -4,6 +4,7 @@ from contextlib import asynccontextmanager
from typing import Dict, Any
import aiohttp
from yarl import URL
from pyhon import const
from pyhon.connection.handler.base import ConnectionHandler
@ -17,10 +18,10 @@ class HonAnonymousConnectionHandler(ConnectionHandler):
@asynccontextmanager
async def _intercept(
self, method: Callback, *args: Any, **kwargs: Any
self, method: Callback, url: str | URL, *args: Any, **kwargs: Dict[str, Any]
) -> AsyncIterator[aiohttp.ClientResponse]:
kwargs["headers"] = kwargs.pop("headers", {}) | self._HEADERS
async with method(*args, **kwargs) as response:
async with method(url, *args, **kwargs) as response:
if response.status == 403:
_LOGGER.error("Can't authenticate anymore")
yield response