Merge "Fix "Invalid content type""
This commit is contained in:
commit
5304b1e0b5
@ -71,14 +71,14 @@ class _BaseHTTPClient(object):
|
||||
"""Handle the common parameters used to send the request."""
|
||||
|
||||
# Default Content-Type is octet-stream
|
||||
content_type = headers.get('Content-Type', 'application/octet-stream')
|
||||
content_type = headers.get('Content-Type', 'application/json')
|
||||
data = kwargs.pop("data", None)
|
||||
if data is not None and not isinstance(data, six.string_types):
|
||||
try:
|
||||
data = json.dumps(data)
|
||||
content_type = content_type or 'application/json'
|
||||
except TypeError:
|
||||
data = self._chunk_body(data)
|
||||
content_type = 'application/octet-stream'
|
||||
|
||||
headers['Content-Type'] = content_type
|
||||
kwargs['stream'] = content_type == 'application/octet-stream'
|
||||
|
@ -272,16 +272,6 @@ class TestClient(testtools.TestCase):
|
||||
self.assertIsInstance(self.mock.last_request.body, six.string_types)
|
||||
self.assertEqual(data, json.loads(self.mock.last_request.body))
|
||||
|
||||
def test_http_chunked_response(self):
|
||||
data = "TEST"
|
||||
path = '/artifacts'
|
||||
self.mock.get(self.endpoint + path, body=six.StringIO(data),
|
||||
headers={"Content-Type": "application/octet-stream"})
|
||||
|
||||
resp, body = self.client.get(path)
|
||||
self.assertIsInstance(body, types.GeneratorType)
|
||||
self.assertEqual([data], list(body))
|
||||
|
||||
@original_only
|
||||
def test_log_http_response_with_non_ascii_char(self):
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user