From f2c5384699c5b8bdc11f1d98030944b5e6b356a4 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Fri, 14 May 2021 15:35:22 +0200 Subject: [PATCH] fix redirect --- stream.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/stream.py b/stream.py index 0047ac1..040360a 100755 --- a/stream.py +++ b/stream.py @@ -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,11 +335,8 @@ 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: - self.redirect(upstream, status=303) + upstream = await handler.proxy.proxy_url(upstream, None) + self.redirect(upstream, status=303) else: self.set_header("Content-Type", "application/vnd.apple.mpegurl") self.write(data)