From a069c4a56aeab0a55740ae8b543c9f0af53bec37 Mon Sep 17 00:00:00 2001 From: Jenifer Tabita Ciuciu-Kiss Date: Tue, 22 Oct 2024 10:21:24 +0200 Subject: [PATCH] fix https do_intercept issue --- ontologytimemachine/proxy_wrapper.py | 12 ++++++------ ontologytimemachine/utils/proxy_logic.py | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ontologytimemachine/proxy_wrapper.py b/ontologytimemachine/proxy_wrapper.py index c612db0..8ef2a74 100644 --- a/ontologytimemachine/proxy_wrapper.py +++ b/ontologytimemachine/proxy_wrapper.py @@ -80,7 +80,10 @@ def get_request_host(self) -> str: return self.request.host.decode("utf-8") def get_request_path(self) -> str: - return self.request.path.decode("utf-8") + if self.request.path: + return self.request.path.decode("utf-8") + else: + return "" def set_request_path(self, new_path: str) -> None: self.request.path = new_path.encode("utf-8") @@ -102,15 +105,12 @@ def set_request_accept_header(self, mime_type: str) -> None: def get_request_url_host_path(self) -> Tuple[str, str, str]: logger.info("Get ontology from request") - if ( - (self.is_get_request or self.is_head_request) - and not self.request.host - and not self.get_request_host() - ): + if (self.is_get_request or self.is_head_request) and not self.request.host: for k, v in self.request.headers.items(): if v[0].decode("utf-8") == "Host": host = v[1].decode("utf-8") path = self.get_request_path() + break url = f"https://{host}{path}" else: host = self.get_request_host() diff --git a/ontologytimemachine/utils/proxy_logic.py b/ontologytimemachine/utils/proxy_logic.py index 275511f..a7db142 100644 --- a/ontologytimemachine/utils/proxy_logic.py +++ b/ontologytimemachine/utils/proxy_logic.py @@ -94,6 +94,9 @@ def is_archivo_ontology_request(wrapped_request): # Extract the request's host and path request_host = wrapped_request.get_request_host() request_path = wrapped_request.get_request_path() + + if not request_path: + return any(request_host == url_host for url_host, _ in ARCHIVO_PARSED_URLS) if (request_host, request_path) in ARCHIVO_PARSED_URLS: logger.info(f"Requested URL: {request_host+request_path} is in Archivo")