fix redirect
This commit is contained in:
parent
b67b8558d0
commit
f2c5384699
10
stream.py
10
stream.py
@ -48,6 +48,7 @@ class ProxyElem():
|
|||||||
return resp.headers.get("Content-Type", "binary/octet-stream")
|
return resp.headers.get("Content-Type", "binary/octet-stream")
|
||||||
async def proxy_url(self, current, path):
|
async def proxy_url(self, current, path):
|
||||||
data = {}
|
data = {}
|
||||||
|
data_list = [data]
|
||||||
if path is None:
|
if path is None:
|
||||||
data["upstream"] = current
|
data["upstream"] = current
|
||||||
else:
|
else:
|
||||||
@ -61,7 +62,7 @@ class ProxyElem():
|
|||||||
if proxy_server is None:
|
if proxy_server is None:
|
||||||
return data["upstream"]
|
return data["upstream"]
|
||||||
async with self.session() as session:
|
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()
|
text = await resp.text()
|
||||||
jdata = json.loads(text)
|
jdata = json.loads(text)
|
||||||
logger.info(jdata)
|
logger.info(jdata)
|
||||||
@ -334,11 +335,8 @@ class MainHandler(tornado.web.RequestHandler):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info(e)
|
logger.info(e)
|
||||||
if data is None:
|
if data is None:
|
||||||
links = await handler.proxy.proxy_url(upstream, None)
|
upstream = await handler.proxy.proxy_url(upstream, None)
|
||||||
if isinstance(links, list) and len(links) == 1:
|
self.redirect(upstream, status=303)
|
||||||
self.redirect(links[0], status=303)
|
|
||||||
else:
|
|
||||||
self.redirect(upstream, status=303)
|
|
||||||
else:
|
else:
|
||||||
self.set_header("Content-Type", "application/vnd.apple.mpegurl")
|
self.set_header("Content-Type", "application/vnd.apple.mpegurl")
|
||||||
self.write(data)
|
self.write(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user