mirror of
https://github.com/sprockets/sprockets.mixins.http.git
synced 2024-11-14 19:29:31 +00:00
Merge pull request #44 from cwille97/fix_key_error
Check explicitly for None
This commit is contained in:
commit
7c1d3184db
2 changed files with 16 additions and 1 deletions
|
@ -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))
|
||||
|
|
15
tests.py
15
tests.py
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue