auth_token: set correct charset when replying with 401

The Content-Type header does not contain the charset used for the
message. It's now required by webob:

  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py35-mysql-ubuntu-xenial/.tox/py35-mysql/lib/python3.5/site-packages/keystonemiddleware/auth_token/__init__.py", line 331, in __call__
    response = self.process_request(req)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py35-mysql-ubuntu-xenial/.tox/py35-mysql/lib/python3.5/site-packages/keystonemiddleware/auth_token/__init__.py", line 650, in process_request
    content_type='application/json')
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py35-mysql-ubuntu-xenial/.tox/py35-mysql/lib/python3.5/site-packages/webob/exc.py", line 268, in __init__'
    **kw)
  File "/home/jenkins/workspace/gate-gnocchi-tox-db-py35-mysql-ubuntu-xenial/.tox/py35-mysql/lib/python3.5/site-packages/webob/response.py", line 310, in __init__'
    "You cannot set the body to a text value without a "
TypeError: You cannot set the body to a text value without a charset

Change-Id: Ia6c667c9afcba0811f51f3e50f34de05310d1433
This commit is contained in:
Julien Danjou 2016-12-28 16:52:01 +01:00
parent 3e6c3ff6bd
commit 20fb1dbe5a

View File

@ -647,7 +647,7 @@ class AuthProtocol(BaseAuthProtocol):
raise webob.exc.HTTPUnauthorized(
body=jsonutils.dumps(body),
headers=self._reject_auth_headers,
content_type='application/json')
content_type='application/json; charset=UTF-8')
if request.user_token_valid:
request.set_user_headers(request.token_auth.user)