diff 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
line wrap: on
line diff
--- a/libervia/server/server.py	Sun Sep 13 15:01:22 2020 +0200
+++ b/libervia/server/server.py	Sun Sep 13 15:01:24 2020 +0200
@@ -1646,11 +1646,11 @@
         self.new_port = new_port
 
     def render(self, request):
-        netloc = request.URLPath().netloc.replace(
-            ":%s" % self.old_port, ":%s" % self.new_port
+        netloc = request.URLPath().netloc.decode().replace(
+            f":{self.old_port}", f":{self.new_port}"
         )
-        url = "https://" + netloc + request.uri
-        return web_util.redirectTo(url, request)
+        url = f"https://{netloc}{request.uri.decode()}"
+        return web_util.redirectTo(url.encode(), request)
 
 
 registerAdapter(session_iface.SATSession, server.Session, session_iface.ISATSession)