diff --git a/src/flask_debugtoolbar/__init__.py b/src/flask_debugtoolbar/__init__.py index 15f4772..3b3a7b7 100644 --- a/src/flask_debugtoolbar/__init__.py +++ b/src/flask_debugtoolbar/__init__.py @@ -230,7 +230,8 @@ def process_response(self, response): response.headers['content-type'].startswith('text/html')): return response - if 'gzip' in response.headers.get('Content-Encoding'): + content_encoding = response.headers.get('Content-Encoding') + if content_encoding and 'gzip' in content_encoding: response_html = gzip_decompress(response.data).decode() else: response_html = response.get_data(as_text=True) @@ -258,7 +259,7 @@ def process_response(self, response): content = ''.join((before, toolbar_html, after)) content = content.encode('utf-8') - if 'gzip' in response.headers.get('Content-Encoding'): + if content_encoding and 'gzip' in content_encoding: content = gzip_compress(content) response.response = [content] response.content_length = len(content) diff --git a/test/basic_app.py b/test/basic_app.py index e10671d..9c3618d 100644 --- a/test/basic_app.py +++ b/test/basic_app.py @@ -4,6 +4,7 @@ from flask_debugtoolbar import DebugToolbarExtension app = Flask('basic_app') +app.config['DEBUG'] = True app.config['SECRET_KEY'] = 'abc123' app.config['SQLALCHEMY_RECORD_QUERIES'] = True app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'