comparison libervia/server/server.py @ 1354:4751e9febbbf

server: fixed HTTPS redirection
author Goffi <goffi@goffi.org>
date Sun, 13 Sep 2020 15:01:24 +0200
parents eb85ef26cb4a
children 2da573bf3f8b
comparison
equal deleted inserted replaced
1353:d1032f9ece5b 1354:4751e9febbbf
1644 self.isLeaf = True 1644 self.isLeaf = True
1645 self.old_port = old_port 1645 self.old_port = old_port
1646 self.new_port = new_port 1646 self.new_port = new_port
1647 1647
1648 def render(self, request): 1648 def render(self, request):
1649 netloc = request.URLPath().netloc.replace( 1649 netloc = request.URLPath().netloc.decode().replace(
1650 ":%s" % self.old_port, ":%s" % self.new_port 1650 f":{self.old_port}", f":{self.new_port}"
1651 ) 1651 )
1652 url = "https://" + netloc + request.uri 1652 url = f"https://{netloc}{request.uri.decode()}"
1653 return web_util.redirectTo(url, request) 1653 return web_util.redirectTo(url.encode(), request)
1654 1654
1655 1655
1656 registerAdapter(session_iface.SATSession, server.Session, session_iface.ISATSession) 1656 registerAdapter(session_iface.SATSession, server.Session, session_iface.ISATSession)
1657 registerAdapter( 1657 registerAdapter(
1658 session_iface.SATGuestSession, server.Session, session_iface.ISATGuestSession 1658 session_iface.SATGuestSession, server.Session, session_iface.ISATGuestSession