This commit is contained in:
yumoqing 2024-02-18 18:20:52 +08:00
parent 95ce487258
commit 9cd3bfe539

View File

@ -167,6 +167,27 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
# print(f'getPostData():{ns=}') # print(f'getPostData():{ns=}')
return 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: async def _handle(self,request:Request) -> StreamResponse:
clientkeys = { clientkeys = {
"iPhone":"iphone", "iPhone":"iphone",
@ -231,6 +252,8 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
async def get_user(): async def get_user():
return await auth.get_auth(request) return await auth.get_auth(request)
self.parse_request(request)
self.y_env.i18n = serveri18n self.y_env.i18n = serveri18n
self.y_env.file_realpath = file_realpath self.y_env.file_realpath = file_realpath
self.y_env.redirect = redirect self.y_env.redirect = redirect