mirror of
https://github.com/sprockets/sprockets.mixins.http.git
synced 2024-11-14 19:29:31 +00:00
Fix exception when correlation_id is None
exception: `TypeError: can only concatenate str (not "NoneType") to str`
This commit is contained in:
parent
b91333aae3
commit
37dc95cb12
2 changed files with 11 additions and 1 deletions
|
@ -446,7 +446,7 @@ class HTTPClientMixin:
|
|||
request_headers.setdefault(
|
||||
'Content-Type',
|
||||
str(content_type) or str(CONTENT_TYPE_MSGPACK))
|
||||
if hasattr(self, 'correlation_id'):
|
||||
if hasattr(self, 'correlation_id') and self.correlation_id:
|
||||
request_headers.setdefault('Correlation-Id', self.correlation_id)
|
||||
elif hasattr(self, 'request') and \
|
||||
self.request.headers.get('Correlation-Id'):
|
||||
|
|
10
tests.py
10
tests.py
|
@ -243,6 +243,16 @@ class MixinTestCase(testing.AsyncHTTPTestCase):
|
|||
self.assertEqual(response.code, 502)
|
||||
self.assertEqual(response.attempts, 3)
|
||||
|
||||
@testing.gen_test
|
||||
def test_correlation_id_is_none(self):
|
||||
mixin = self.create_mixin()
|
||||
mixin.correlation_id = None
|
||||
response = yield mixin.http_fetch(
|
||||
self.get_url('/error?status_code=502'))
|
||||
self.assertFalse(response.ok)
|
||||
self.assertEqual(response.code, 502)
|
||||
self.assertEqual(response.attempts, 3)
|
||||
|
||||
@testing.gen_test
|
||||
def test_get(self):
|
||||
response = yield self.mixin.http_fetch(
|
||||
|
|
Loading…
Reference in a new issue