feat: implement custom socketio headers
This commit is contained in:
parent
cc3588cf4d
commit
e1fd3b7f03
1 changed files with 5 additions and 2 deletions
|
@ -399,15 +399,18 @@ class UptimeKumaApi(object):
|
||||||
|
|
||||||
:param str url: The url to the Uptime Kuma instance. For example ``http://127.0.0.1:3001``
|
:param str url: The url to the Uptime Kuma instance. For example ``http://127.0.0.1:3001``
|
||||||
:param float wait_timeout: How many seconds the client should wait for the connection., defaults to 1
|
:param float wait_timeout: How many seconds the client should wait for the connection., defaults to 1
|
||||||
|
:param dict headers: Headers that are passed to the socketio connection, defaults to None
|
||||||
:raises UptimeKumaException: When connection to server failed.
|
:raises UptimeKumaException: When connection to server failed.
|
||||||
"""
|
"""
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
url: str,
|
url: str,
|
||||||
wait_timeout: float = 1
|
wait_timeout: float = 1,
|
||||||
|
headers: dict = None
|
||||||
) -> None:
|
) -> None:
|
||||||
self.url = url
|
self.url = url
|
||||||
self.wait_timeout = wait_timeout
|
self.wait_timeout = wait_timeout
|
||||||
|
self.headers = headers
|
||||||
self.sio = socketio.Client()
|
self.sio = socketio.Client()
|
||||||
|
|
||||||
self._event_data: dict = {
|
self._event_data: dict = {
|
||||||
|
@ -583,7 +586,7 @@ class UptimeKumaApi(object):
|
||||||
"""
|
"""
|
||||||
url = self.url.rstrip("/")
|
url = self.url.rstrip("/")
|
||||||
try:
|
try:
|
||||||
self.sio.connect(f'{url}/socket.io/', wait_timeout=self.wait_timeout)
|
self.sio.connect(f'{url}/socket.io/', wait_timeout=self.wait_timeout, headers=self.headers)
|
||||||
except:
|
except:
|
||||||
raise UptimeKumaException("unable to connect")
|
raise UptimeKumaException("unable to connect")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue