From 3cf4ebc7978540cee171ab07f20a641d995603d3 Mon Sep 17 00:00:00 2001 From: db0 Date: Fri, 7 Jul 2023 10:14:56 +0200 Subject: [PATCH] avoid_etag_error --- fediseer/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fediseer/__init__.py b/fediseer/__init__.py index 34c201b..791c2a9 100644 --- a/fediseer/__init__.py +++ b/fediseer/__init__.py @@ -19,6 +19,9 @@ def after_request(response): response.headers["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS, PUT, DELETE, PATCH" response.headers["Access-Control-Allow-Headers"] = "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, apikey, Client-Agent, X-Fields" response.headers["Fediseer-Node"] = f"{socket.gethostname()}:{args.port}:{FEDISEER_VERSION}" - etag = hashlib.sha1(response.get_data()).hexdigest() + try: + etag = hashlib.sha1(response.get_data()).hexdigest() + except RuntimeError: + etag = "Runtime Error" response.headers["ETag"] = etag return response