Skip to content

Commit

Permalink
Merge pull request #107 from kuefmz:main
Browse files Browse the repository at this point in the history
Fixing the do_intercept, no request path issue
  • Loading branch information
JJ-Author authored Oct 22, 2024
2 parents c3a0473 + 39b9ab3 commit 2a9452b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ontologytimemachine/proxy_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions ontologytimemachine/utils/proxy_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 2a9452b

Please sign in to comment.