diff options
author | Julien Danjou <julien@danjou.info> | 2014-04-24 17:48:48 +0200 |
---|---|---|
committer | Julien Danjou <julien@danjou.info> | 2014-04-24 18:25:17 +0200 |
commit | 60f8d4b1877d5a235be4aaf216d64a6b0c0b7249 (patch) | |
tree | b0650a54d75cfe684a0a6ba10cb566f0cb008f0f /pecan | |
parent | 7e6e3fc8766d6331165e1a06f163a90e579b1d03 (diff) | |
download | pecan-60f8d4b1877d5a235be4aaf216d64a6b0c0b7249.tar.gz |
Do not include Content-Type on 204 and 304 status codes
Change-Id: Iec7e5e0a7d5f10bf264a2e8e0a01cdaf2d73fd86
Diffstat (limited to 'pecan')
-rw-r--r-- | pecan/core.py | 8 | ||||
-rw-r--r-- | pecan/tests/test_base.py | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/pecan/core.py b/pecan/core.py index 5804e19..76fc975 100644 --- a/pecan/core.py +++ b/pecan/core.py @@ -552,10 +552,12 @@ class Pecan(object): elif result: resp.body = result elif response.status_int == 200: - response.status = 204 + resp.status = 204 - # set the content type - if pecan_state['content_type']: + if resp.status_int in (204, 304): + resp.content_type = None + elif pecan_state['content_type']: + # set the content type resp.content_type = pecan_state['content_type'] def __call__(self, environ, start_response): diff --git a/pecan/tests/test_base.py b/pecan/tests/test_base.py index 96f7757..050ac6d 100644 --- a/pecan/tests/test_base.py +++ b/pecan/tests/test_base.py @@ -47,6 +47,7 @@ class TestEmptyContent(PecanTestCase): def test_empty_index(self): r = self.app_.get('/') self.assertEqual(r.status_int, 204) + self.assertNotIn('Content-Type', r.headers) self.assertEqual(r.headers['Content-Length'], '0') self.assertEqual(len(r.body), 0) |