bugfix
This commit is contained in:
parent
de575af543
commit
ee1c8ceb5f
40
ahserver/proxyProcessor.py
Normal file
40
ahserver/proxyProcessor.py
Normal file
@ -0,0 +1,40 @@
|
||||
from aiohttp import web
|
||||
from aiohttp import client
|
||||
from .baseProcessor import *
|
||||
|
||||
class proxyProcessor(BaseProcessor):
|
||||
@classmethod
|
||||
def isMe(self,name):
|
||||
return name=='proxy'
|
||||
|
||||
async def path_call(self, request, params={}):
|
||||
await self.set_run_env(request)
|
||||
path = self.path
|
||||
url = self.resource.entireUrl(request, path)
|
||||
ns = self.run_ns
|
||||
ns.update(params)
|
||||
te = self.run_ns['tmpl_engine']
|
||||
txt = await te.render(url,**ns)
|
||||
data = json.loads(txt)
|
||||
return data
|
||||
|
||||
async def datahandle(self,request):
|
||||
d = await self.path_call(request)
|
||||
reqH = request.headers.copy()
|
||||
async with client.request(
|
||||
request.method,
|
||||
d['url'],
|
||||
headers = reqH,
|
||||
allow_redirects=False,
|
||||
data=await req.read()) as res:
|
||||
headers = res.headers.copy()
|
||||
body = await res.read()
|
||||
self.retResponse = web.Response(
|
||||
headers = headers,
|
||||
status = res.status,
|
||||
body = body
|
||||
)
|
||||
|
||||
def setheaders(self):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user