Skip to content

Commit

Permalink
encode and decode for python3
Browse files Browse the repository at this point in the history
  • Loading branch information
knorth55 committed Mar 24, 2023
1 parent c4b4d43 commit 7e0907c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/roswww/roswww_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import base64
import functools
import socket
import sys
import tornado.ioloop # rosbridge installs tornado
import tornado.web
import yaml
Expand All @@ -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):
Expand Down

0 comments on commit 7e0907c

Please sign in to comment.