diff --git a/sanic/response.py b/sanic/response.py index f4e24e99..d5b2beae 100644 --- a/sanic/response.py +++ b/sanic/response.py @@ -97,9 +97,10 @@ class HTTPResponse: headers = b'' if self.headers: headers = b''.join( - b'%b: %b\r\n' % (name.encode(), str(value).encode('utf-8')) - if type(value) != Cookie else b'%b: %b\r\n' % (name.encode(), value.encode('utf-8')) + if isinstance(value, str) or isinstance(value, Cookie) + else b'%b: %b\r\n' % (name.encode(), + str(value).encode('utf-8')) for name, value in self.headers.items() )