This commit is contained in:
yumoqing 2024-02-19 11:40:55 +08:00
parent 79c27fe16a
commit 01c7ef6c7a

View File

@ -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):