mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Add Python 3 support to _get_user().
This commit is contained in:
parent
5f3dc8ed2b
commit
117ef10176
@ -14,7 +14,7 @@ import sys
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from gunicorn import util
|
from gunicorn import util
|
||||||
from gunicorn.six import string_types
|
from gunicorn.six import PY3, string_types
|
||||||
|
|
||||||
|
|
||||||
# syslog facility codes
|
# syslog facility codes
|
||||||
@ -378,10 +378,13 @@ class Logger(object):
|
|||||||
auth = http_auth.split(" ", 1)
|
auth = http_auth.split(" ", 1)
|
||||||
if len(auth) == 2:
|
if len(auth) == 2:
|
||||||
try:
|
try:
|
||||||
auth = base64.b64decode(auth[1].strip()).split(":", 1)
|
auth = base64.b64decode(auth[1].strip())
|
||||||
except TypeError:
|
if PY3: # b64decode returns a byte string in Python 3
|
||||||
|
auth = auth.decode('utf-8')
|
||||||
|
auth = auth.split(":", 1)
|
||||||
|
except TypeError as exc:
|
||||||
|
self.debug("Couldn't get username: %s", exc)
|
||||||
return user
|
return user
|
||||||
if len(auth) == 2:
|
if len(auth) == 2:
|
||||||
user = auth[0]
|
user = auth[0]
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user