From 9cd3bfe5390488a6a5957e384206f71b8883672a Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 18 Feb 2024 18:20:52 +0800 Subject: [PATCH] bugfix --- ahserver/processorResource.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ahserver/processorResource.py b/ahserver/processorResource.py index 41f02ba..aeaf235 100755 --- a/ahserver/processorResource.py +++ b/ahserver/processorResource.py @@ -167,6 +167,27 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): # print(f'getPostData():{ns=}') return ns + def parse_request(self, request): + """ + get real schema, host, port, prepath + and save it to self._{attr} + + """ + self._scheme = request.scheme + + self._scheme = request.headers.get('X-Forwarded-Scheme',request.scheme) + k = request.host.split(':') + host = k[0] + port = 80 + if len(k) == 2: + port = int(k[1]) + elif self._scheme.lower() == 'https': + port = 443 + + 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', '') + async def _handle(self,request:Request) -> StreamResponse: clientkeys = { "iPhone":"iphone", @@ -231,6 +252,8 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): async def get_user(): return await auth.get_auth(request) + self.parse_request(request) + self.y_env.i18n = serveri18n self.y_env.file_realpath = file_realpath self.y_env.redirect = redirect