summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJason Madden <jason+github@nextthought.com>2020-01-13 06:40:40 -0600
committerChris Dent <cdent@anticdent.org>2020-01-13 12:40:40 +0000
commitd38247d52c03ebf66a922ac1a1fa2cc9a77789ca (patch)
tree333b69fe1acde89b99093cc38128d55ba6ca78dc /tests
parent1cc7e73f9980618f620d8e176858fe8f59ed03fc (diff)
downloadpaste-git-d38247d52c03ebf66a922ac1a1fa2cc9a77789ca.tar.gz
Make gzip middleware stop producing a spurious response body on HEAD requests. (#44)
Fixes #43
Diffstat (limited to 'tests')
-rw-r--r--tests/test_gzipper.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/test_gzipper.py b/tests/test_gzipper.py
index 54b7901..d56c406 100644
--- a/tests/test_gzipper.py
+++ b/tests/test_gzipper.py
@@ -4,8 +4,10 @@ import gzip
import six
def simple_app(environ, start_response):
- start_response('200 OK', [('content-type', 'text/plain')])
- return [b'this is a test']
+ start_response('200 OK',
+ [('content-type', 'text/plain'),
+ ('content-length', '0')])
+ return [b'this is a test'] if environ['REQUEST_METHOD'] != 'HEAD' else []
wsgi_app = middleware(simple_app)
app = TestApp(wsgi_app)
@@ -17,3 +19,9 @@ def test_gzip():
assert res.body != b'this is a test'
actual = gzip.GzipFile(fileobj=six.BytesIO(res.body)).read()
assert actual == b'this is a test'
+
+def test_gzip_head():
+ res = app.head(
+ '/', extra_environ=dict(HTTP_ACCEPT_ENCODING='gzip'))
+ assert int(res.header('content-length')) == 0
+ assert res.body == b''