From 01c7ef6c7aad4c096d54790aaef4758bf4f813cb Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 19 Feb 2024 11:40:55 +0800 Subject: [PATCH] bugfix --- ahserver/processorResource.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/ahserver/processorResource.py b/ahserver/processorResource.py index 15ee32e..aea2829 100755 --- a/ahserver/processorResource.py +++ b/ahserver/processorResource.py @@ -189,6 +189,9 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): self._host = request.headers.get('X-Forwarded-Host', host) self._port = request.headers.get('X-Forwarded-Port', port) self._prepath = request.headers.get('X-Forwarded-Prepath', '') + if self._prepath != '': + self._prepath = '/' + self._prepath + self._preurl = f'{self._scheme}://{self._host}:{self._port}{self._prepath}' print(f'{request.path=}, {self._preurl=}') @@ -405,19 +408,11 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): url.startswith('ws://') or \ url.startswith('wss://'): return url - scheme = self._scheme - port = self._port - prepath = self._prepath - if prepath != '': - prepath = f'/{prepath}' - h = self._host if url.startswith('/'): - return f'{scheme}://{h}:{port}{prepath}{url}' + return f'{self._prepath}{url}' path = request.path - if self.request_filename and os.path.isdir(self.request_filename): - path = '%s/oops' % path p = self.relatedurl(path,url) - return f'{scheme}://{h}:{port}{prepath}{p}' + return f'{self._prepath}{p}' def url2path(self, url): if url.startswith(self._prepath):