From 20fb1dbe5a884ecdbf6ee5ea26b2660f7a7e4b1e Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 28 Dec 2016 16:52:01 +0100 Subject: [PATCH] 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 --- keystonemiddleware/auth_token/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keystonemiddleware/auth_token/__init__.py b/keystonemiddleware/auth_token/__init__.py index cfdc01c8..a136a65d 100644 --- a/keystonemiddleware/auth_token/__init__.py +++ b/keystonemiddleware/auth_token/__init__.py @@ -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)