diff options
-rw-r--r-- | pecan/core.py | 2 | ||||
-rw-r--r-- | pecan/tests/test_base.py | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/pecan/core.py b/pecan/core.py index 0aad76a..15d47f7 100644 --- a/pecan/core.py +++ b/pecan/core.py @@ -539,7 +539,7 @@ class Pecan(object): # set the body content if isinstance(result, six.text_type): resp.text = result - else: + elif result: resp.body = result # set the content type diff --git a/pecan/tests/test_base.py b/pecan/tests/test_base.py index e5ec6af..d9808a0 100644 --- a/pecan/tests/test_base.py +++ b/pecan/tests/test_base.py @@ -33,6 +33,23 @@ class TestAppRoot(PecanTestCase): assert app.root and isinstance(app.root, SampleRootController) +class TestEmptyContent(PecanTestCase): + @property + def app_(self): + class RootController(object): + @expose() + def index(self): + pass + + return TestApp(Pecan(RootController())) + + def test_empty_index(self): + r = self.app_.get('/') + self.assertEqual(r.status_int, 200) + self.assertEqual(r.headers['Content-Length'], '0') + self.assertEqual(len(r.body), 0) + + class TestIndexRouting(PecanTestCase): @property |