diff src/server/server.py @ 867:12d0e7bd0dd1

server: fixed encoding issues on url redirection
author Goffi <goffi@goffi.org>
date Fri, 26 Feb 2016 19:26:29 +0100
parents 782ba105f5c7
children fa7703642c0e
line wrap: on
line diff
--- a/src/server/server.py	Wed Feb 24 12:09:28 2016 +0100
+++ b/src/server/server.py	Fri Feb 26 19:26:29 2016 +0100
@@ -152,7 +152,7 @@
                 if new_url.netloc:
                     raise NotImplementedError(u"netloc ({netloc}) is not implemented yet for url_redirections_dict, it is not possible to redirect to an external website".format(
                         netloc = new_url.netloc))
-                location = urlparse.urlunsplit(('', '', new_url.path, new_url.query, new_url.fragment))
+                location = urlparse.urlunsplit(('', '', new_url.path, new_url.query, new_url.fragment)).decode('utf-8')
                 request_data = self._getRequestData(location)
             else:
                 raise NotImplementedError(u"{scheme}: scheme is not managed for url_redirections_dict".format(scheme=new_url.scheme))
@@ -217,13 +217,13 @@
             pass
         else:
             log.warning(D_(u"recursive redirection, please fix this URL:\n{old} ==> {new}").format(
-                old=request.uri,
-                new=uri,
+                old=request.uri.decode('utf-8'),
+                new=uri.decode('utf-8'),
                 ))
             return web_resource.NoResource()
         log.debug(u"Redirecting URL {old} to {new}".format(
-            old=request.uri,
-            new=uri,
+            old=request.uri.decode('utf-8'),
+            new=uri.decode('utf-8'),
             ))
         # we change the request to reflect the new url
         request._redirected = True # here to avoid recursive redirections