From 7e0907c413f044d3e301672ef7981262a236a814 Mon Sep 17 00:00:00 2001 From: Shingo Kitagawa Date: Fri, 24 Mar 2023 23:53:57 +0900 Subject: [PATCH] encode and decode for python3 --- src/roswww/roswww_server.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/roswww/roswww_server.py b/src/roswww/roswww_server.py index fe09b25..0b9f563 100644 --- a/src/roswww/roswww_server.py +++ b/src/roswww/roswww_server.py @@ -39,6 +39,7 @@ import base64 import functools import socket +import sys import tornado.ioloop # rosbridge installs tornado import tornado.web import yaml @@ -64,7 +65,10 @@ def new_f(*args): if not auth_header.startswith('Basic '): return _request_auth(handler) - auth_decoded = base64.decodestring(auth_header.split(' ', 1)[1]) + if sys.version_info.major >= 3: + auth_decoded = base64.decodestring(auth_header.split(' ', 1)[1].encode('ascii')).decode('utf-8') + else: + auth_decoded = base64.decodestring(auth_header.split(' ', 1)[1]) username, password = auth_decoded.split(':', 1) if auth(username, password):