Add Accept: applicaton/json header to all service requests. Fixes bug 904436
Change-Id: I5f7c78f0ea516a7a96c32b1f745686e130c2b9af
This commit is contained in:
parent
ae10b4bf58
commit
fe4fa9daef
1
AUTHORS
1
AUTHORS
|
@ -32,6 +32,7 @@ Kiall Mac Innes <kiall@managedit.ie>
|
|||
Kirill Shileev <kshileev@griddynamics.com>
|
||||
Lvov Maxim <mlvov@mirantis.com>
|
||||
Matt Dietz <matt.dietz@rackspace.com>
|
||||
Matt Stephenson <mattstep@mattstep.net>
|
||||
Nicholas Mistry <nmistry@gmail.com>
|
||||
Nikolay Sokolov <nsokolov@griddynamics.com>
|
||||
Pavel Shkitin <pshkitin@griddynamics.com>
|
||||
|
|
|
@ -82,6 +82,7 @@ class HTTPClient(httplib2.Http):
|
|||
def request(self, *args, **kwargs):
|
||||
kwargs.setdefault('headers', kwargs.get('headers', {}))
|
||||
kwargs['headers']['User-Agent'] = self.USER_AGENT
|
||||
kwargs['headers']['Accept'] = 'application/json'
|
||||
if 'body' in kwargs:
|
||||
kwargs['headers']['Content-Type'] = 'application/json'
|
||||
kwargs['body'] = json.dumps(kwargs['body'])
|
||||
|
|
|
@ -36,6 +36,7 @@ class ClientTest(utils.TestCase):
|
|||
headers = {"X-Auth-Token": "token",
|
||||
"X-Auth-Project-Id": "project_id",
|
||||
"User-Agent": cl.USER_AGENT,
|
||||
'Accept': 'application/json',
|
||||
}
|
||||
mock_request.assert_called_with("http://example.com/hi",
|
||||
"GET", headers=headers)
|
||||
|
@ -54,6 +55,7 @@ class ClientTest(utils.TestCase):
|
|||
"X-Auth-Token": "token",
|
||||
"X-Auth-Project-Id": "project_id",
|
||||
"Content-Type": "application/json",
|
||||
'Accept': 'application/json',
|
||||
"User-Agent": cl.USER_AGENT
|
||||
}
|
||||
mock_request.assert_called_with("http://example.com/hi", "POST",
|
||||
|
|
|
@ -55,6 +55,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||
headers = {
|
||||
'User-Agent': cs.client.USER_AGENT,
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
}
|
||||
body = {
|
||||
'auth': {
|
||||
|
@ -152,6 +153,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||
headers = {
|
||||
'User-Agent': cs.client.USER_AGENT,
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
}
|
||||
body = {
|
||||
'auth': {
|
||||
|
@ -244,6 +246,7 @@ class AuthenticationTests(utils.TestCase):
|
|||
def test_auth_call():
|
||||
cs.client.authenticate()
|
||||
headers = {
|
||||
'Accept': 'application/json',
|
||||
'X-Auth-User': 'username',
|
||||
'X-Auth-Key': 'password',
|
||||
'X-Auth-Project-Id': 'project_id',
|
||||
|
|
Loading…
Reference in New Issue