Merge pull request #44 from cwille97/fix_key_error

Check explicitly for None
This commit is contained in:
dave-shawley 2022-05-05 21:51:28 -04:00 committed by GitHub
commit 7c1d3184db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -452,7 +452,7 @@ class HTTPClientMixin:
request_headers = {}
request_headers.setdefault(
'Accept', ', '.join([str(ct) for ct in AVAILABLE_CONTENT_TYPES]))
if body:
if body is not None:
request_headers.setdefault(
'Content-Type',
str(content_type) or str(CONTENT_TYPE_MSGPACK))

View file

@ -803,3 +803,18 @@ class MixinTestCase(testing.AsyncHTTPTestCase):
self.assertEqual(response.headers['Content-Type'],
'bar/foo+json')
self.assertEqual(response.body['body'], body)
@testing.gen_test
def test_post_without_content_type(self):
body = {
'foo': 'bar',
}
response = yield self.mixin.http_fetch(
self.get_url('/test'),
method='POST',
body=body,
request_headers={},
)
self.assertEqual(response.code, 200)
self.assertEqual(response.body['headers']['Content-Type'],
'application/msgpack')