fix redirect

This commit is contained in:
Roy Olav Purser 2021-05-14 15:35:22 +02:00
parent b67b8558d0
commit f2c5384699
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -48,6 +48,7 @@ class ProxyElem():
return resp.headers.get("Content-Type", "binary/octet-stream")
async def proxy_url(self, current, path):
data = {}
data_list = [data]
if path is None:
data["upstream"] = current
else:
@ -61,7 +62,7 @@ class ProxyElem():
if proxy_server is None:
return data["upstream"]
async with self.session() as session:
resp = await session.post(proxy_server, json=[data])
resp = await session.post(proxy_server, json=data_list)
text = await resp.text()
jdata = json.loads(text)
logger.info(jdata)
@ -334,10 +335,7 @@ class MainHandler(tornado.web.RequestHandler):
except Exception as e:
logger.info(e)
if data is None:
links = await handler.proxy.proxy_url(upstream, None)
if isinstance(links, list) and len(links) == 1:
self.redirect(links[0], status=303)
else:
upstream = await handler.proxy.proxy_url(upstream, None)
self.redirect(upstream, status=303)
else:
self.set_header("Content-Type", "application/vnd.apple.mpegurl")