bugfix
This commit is contained in:
parent
9548d7ae33
commit
52b21ad388
@ -171,9 +171,6 @@ class ProcessorResource(StaticResource,Url2File):
|
|||||||
l = c.langMapping.get(lang,lang)
|
l = c.langMapping.get(lang,lang)
|
||||||
return g.myi18n(s,l)
|
return g.myi18n(s,l)
|
||||||
|
|
||||||
def gethost():
|
|
||||||
return '/'.join(str(request.url).split('/')[:3])
|
|
||||||
|
|
||||||
|
|
||||||
async def getArgs():
|
async def getArgs():
|
||||||
ns = DictObject()
|
ns = DictObject()
|
||||||
@ -190,7 +187,7 @@ class ProcessorResource(StaticResource,Url2File):
|
|||||||
self.y_env.abspath = self.abspath
|
self.y_env.abspath = self.abspath
|
||||||
self.y_env.request2ns = getArgs
|
self.y_env.request2ns = getArgs
|
||||||
self.y_env.resource = self
|
self.y_env.resource = self
|
||||||
self.y_env.gethost = gethost
|
self.y_env.gethost = partial(self.gethost, request)
|
||||||
self.y_env.path_call = partial(self.path_call,request)
|
self.y_env.path_call = partial(self.path_call,request)
|
||||||
self.user = await auth.get_auth(request)
|
self.user = await auth.get_auth(request)
|
||||||
self.y_env.user = self.user
|
self.y_env.user = self.user
|
||||||
@ -243,6 +240,15 @@ class ProcessorResource(StaticResource,Url2File):
|
|||||||
raise HTTPNotFound
|
raise HTTPNotFound
|
||||||
return await super()._handle(request)
|
return await super()._handle(request)
|
||||||
|
|
||||||
|
def gethost(self, request):
|
||||||
|
host = request.headers.get('X-Forwarded-Host')
|
||||||
|
if host:
|
||||||
|
return host
|
||||||
|
host = request.headers.get('Host')
|
||||||
|
if host:
|
||||||
|
return host
|
||||||
|
return '/'.join(str(request.url).split('/')[:3])
|
||||||
|
|
||||||
async def html_handle(self,request,filepath):
|
async def html_handle(self,request,filepath):
|
||||||
with open(filepath,'rb') as f:
|
with open(filepath,'rb') as f:
|
||||||
b = f.read()
|
b = f.read()
|
||||||
@ -273,7 +279,7 @@ class ProcessorResource(StaticResource,Url2File):
|
|||||||
config = getConfig()
|
config = getConfig()
|
||||||
url = self.entireUrl(request, url)
|
url = self.entireUrl(request, url)
|
||||||
host = '/'.join(str(request.url).split('/')[:3])
|
host = '/'.join(str(request.url).split('/')[:3])
|
||||||
path = url[len(host):].split('?')[0]
|
path = request.path #url[len(host):].split('?')[0]
|
||||||
real_path = self.abspath(request, path)
|
real_path = self.abspath(request, path)
|
||||||
if config.website.startswiths:
|
if config.website.startswiths:
|
||||||
for a in config.website.startswiths:
|
for a in config.website.startswiths:
|
||||||
@ -295,14 +301,14 @@ class ProcessorResource(StaticResource,Url2File):
|
|||||||
def entireUrl(self, request, url):
|
def entireUrl(self, request, url):
|
||||||
if url.startswith('http://') or url.startswith('https://'):
|
if url.startswith('http://') or url.startswith('https://'):
|
||||||
return url
|
return url
|
||||||
h = '/'.join(str(request.url).split('/')[:3])
|
h = self.gethost(request)
|
||||||
if url.startswith('/'):
|
if url.startswith('/'):
|
||||||
return '%s%s' % (h,url)
|
return '%s://%s%s' % (request.scheme, h, url)
|
||||||
path = request.path
|
path = request.path
|
||||||
if self.request_filename and os.path.isdir(self.request_filename):
|
if self.request_filename and os.path.isdir(self.request_filename):
|
||||||
path = '%s/oops' % path
|
path = '%s/oops' % path
|
||||||
p = self.relatedurl(path,url)
|
p = self.relatedurl(path,url)
|
||||||
return '%s%s' % (h, p)
|
return '%s://%s%s' % (request.scheme, h, p)
|
||||||
|
|
||||||
async def path_call(self,request, path, params={}):
|
async def path_call(self,request, path, params={}):
|
||||||
url = self.entireUrl(request, path)
|
url = self.entireUrl(request, path)
|
||||||
|
Loading…
Reference in New Issue
Block a user