Skip to content

Commit bdd441d

Browse files
authored
Merge pull request #22 from lucasheld/feature/custom-headers
Feature: Implement custom SocketIO Headers
2 parents d7f0330 + e1fd3b7 commit bdd441d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

uptime_kuma_api/api.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,18 @@ class UptimeKumaApi(object):
356356
357357
:param str url: The url to the Uptime Kuma instance. For example ``http://127.0.0.1:3001``
358358
:param float wait_timeout: How many seconds the client should wait for the connection., defaults to 1
359+
:param dict headers: Headers that are passed to the socketio connection, defaults to None
359360
:raises UptimeKumaException: When connection to server failed.
360361
"""
361362
def __init__(
362363
self,
363364
url: str,
364-
wait_timeout: float = 1
365+
wait_timeout: float = 1,
366+
headers: dict = None
365367
) -> None:
366368
self.url = url
367369
self.wait_timeout = wait_timeout
370+
self.headers = headers
368371
self.sio = socketio.Client()
369372

370373
self._event_data: dict = {
@@ -541,7 +544,7 @@ def connect(self) -> None:
541544
"""
542545
url = self.url.rstrip("/")
543546
try:
544-
self.sio.connect(f'{url}/socket.io/', wait_timeout=self.wait_timeout)
547+
self.sio.connect(f'{url}/socket.io/', wait_timeout=self.wait_timeout, headers=self.headers)
545548
except:
546549
raise UptimeKumaException("unable to connect")
547550

0 commit comments

Comments
 (0)