mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-24 23:41:10 +02:00
support per-request headers
This commit is contained in:
parent
3cf315880d
commit
edf38edc3f
1 changed files with 6 additions and 2 deletions
|
|
@ -61,13 +61,17 @@ class SurfSenseClient:
|
||||||
json: Any | None = None,
|
json: Any | None = None,
|
||||||
data: dict[str, Any] | None = None,
|
data: dict[str, Any] | None = None,
|
||||||
files: Any | None = None,
|
files: Any | None = None,
|
||||||
|
headers: dict[str, str] | None = None,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""Send a request and return the parsed body, or raise ``ToolError``."""
|
"""Send a request and return the parsed body, or raise ``ToolError``.
|
||||||
|
|
||||||
|
``headers`` overrides the client defaults for this call.
|
||||||
|
"""
|
||||||
# Omit unset query params: sending them empty makes the API parse ""
|
# Omit unset query params: sending them empty makes the API parse ""
|
||||||
# as a value (e.g. int("") on folder_id) and fail.
|
# as a value (e.g. int("") on folder_id) and fail.
|
||||||
if params is not None:
|
if params is not None:
|
||||||
params = {key: value for key, value in params.items() if value is not None}
|
params = {key: value for key, value in params.items() if value is not None}
|
||||||
headers = self._auth_headers()
|
headers = {**self._auth_headers(), **(headers or {})}
|
||||||
try:
|
try:
|
||||||
response = await self._http.request(
|
response = await self._http.request(
|
||||||
method,
|
method,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue