diff --git a/gunicorn/http/wsgi.py b/gunicorn/http/wsgi.py index 32e7a2ac..3524471f 100644 --- a/gunicorn/http/wsgi.py +++ b/gunicorn/http/wsgi.py @@ -253,10 +253,13 @@ class Response(object): if HEADER_RE.search(name): raise InvalidHeaderName('%r' % name) + if not isinstance(value, str): + raise TypeError('%r is not a string' % value) + if HEADER_VALUE_RE.search(value): raise InvalidHeader('%r' % value) - value = str(value).strip() + value = value.strip() lname = name.lower().strip() if lname == "content-length": self.response_length = int(value)