summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMichael Manfre2022-12-04 11:32:25 -0500
committerGitHub2022-12-04 09:32:25 -0700
commit61c1058d67ae5621687a95fbc1f6dcc71fbc42a7 (patch)
treee7a8f23198fcca7edaa21c34197d580f2bcc7e67 /core
parent0efa4456051e97040c750d5927304ad4db49bf24 (diff)
downloadtakahe-61c1058d67ae5621687a95fbc1f6dcc71fbc42a7.tar.gz
takahe-61c1058d67ae5621687a95fbc1f6dcc71fbc42a7.tar.bz2
takahe-61c1058d67ae5621687a95fbc1f6dcc71fbc42a7.zip
Add TAKAHE_DEFAULT_TIMEOUT with default of 5.0 (#99)
Diffstat (limited to 'core')
-rw-r--r--core/signatures.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/signatures.py b/core/signatures.py
index e2582c5..ead33da 100644
--- a/core/signatures.py
+++ b/core/signatures.py
@@ -7,9 +7,11 @@ import httpx
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import padding, rsa
+from django.conf import settings
from django.http import HttpRequest
from django.utils import timezone
from django.utils.http import http_date, parse_http_date
+from httpx._types import TimeoutTypes
from pyld import jsonld
from core.ld import format_ld_date
@@ -173,6 +175,7 @@ class HttpSignature:
key_id: str,
content_type: str = "application/json",
method: Literal["get", "post"] = "post",
+ timeout: TimeoutTypes = settings.SETUP.REMOTE_TIMEOUT,
):
"""
Performs an async request to the given path, with a document, signed
@@ -219,7 +222,7 @@ class HttpSignature:
)
# Send the request with all those headers except the pseudo one
del headers["(request-target)"]
- async with httpx.AsyncClient() as client:
+ async with httpx.AsyncClient(timeout=timeout) as client:
response = await client.request(
method,
uri,