diff --git a/sushy/connector.py b/sushy/connector.py index 003f4b91..f8a9f82f 100644 --- a/sushy/connector.py +++ b/sushy/connector.py @@ -93,7 +93,10 @@ class Connector(object): url = path if urlparse.urlparse(path).netloc else urlparse.urljoin( self._url, path) headers = headers or {} - if not any(k.lower() == 'odata-version' for k in headers): + lc_headers = [k.lower() for k in headers] + if data is not None and 'content-type' not in lc_headers: + headers['Content-Type'] = 'application/json' + if 'odata-version' not in lc_headers: headers['OData-Version'] = '4.0' # TODO(lucasagomes): We should mask the data to remove sensitive # information diff --git a/sushy/tests/unit/test_connector.py b/sushy/tests/unit/test_connector.py index 0e131ab8..729a6779 100644 --- a/sushy/tests/unit/test_connector.py +++ b/sushy/tests/unit/test_connector.py @@ -220,6 +220,7 @@ class ConnectorOpTestCase(base.TestCase): self.conn._session.headers['X-Auth-Token'] = 'asdf1234' expected_headers = self.headers.copy() expected_headers['OData-Version'] = '4.0' + expected_headers['Content-Type'] = 'application/json' self.conn._op('POST', path='fake/path', headers=self.headers, data=self.data) self.request.assert_called_once_with(