summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-04-23 16:59:52 +0000
committerGerrit Code Review <review@openstack.org>2014-04-23 16:59:52 +0000
commit5ede5e03572c873ff533ef9c2c0db5f92a8bc6ce (patch)
tree448454882b695c9fdbf4324230ed2fe091e02656
parent7622e089846ea3b719d13674317005a153ad08b3 (diff)
parent87418bb069a3357a260d518f67d46ba37994cdbb (diff)
downloadpecan-5ede5e03572c873ff533ef9c2c0db5f92a8bc6ce.tar.gz
Merge "If an exposed method returns nothing, reply with an HTTP 204."
-rw-r--r--pecan/core.py4
-rw-r--r--pecan/tests/test_base.py4
2 files changed, 5 insertions, 3 deletions
diff --git a/pecan/core.py b/pecan/core.py
index f7603ba..5804e19 100644
--- a/pecan/core.py
+++ b/pecan/core.py
@@ -547,10 +547,12 @@ class Pecan(object):
testing_variables['controller_output'] = result
# set the body content
- if isinstance(result, six.text_type):
+ if result and isinstance(result, six.text_type):
resp.text = result
elif result:
resp.body = result
+ elif response.status_int == 200:
+ response.status = 204
# set the content type
if pecan_state['content_type']:
diff --git a/pecan/tests/test_base.py b/pecan/tests/test_base.py
index 1ae1e79..96f7757 100644
--- a/pecan/tests/test_base.py
+++ b/pecan/tests/test_base.py
@@ -46,7 +46,7 @@ class TestEmptyContent(PecanTestCase):
def test_empty_index(self):
r = self.app_.get('/')
- self.assertEqual(r.status_int, 200)
+ self.assertEqual(r.status_int, 204)
self.assertEqual(r.headers['Content-Length'], '0')
self.assertEqual(len(r.body), 0)
@@ -1005,7 +1005,7 @@ class TestFileTypeExtensions(PecanTestCase):
def test_hidden_file(self):
r = self.app_.get('/.vimrc')
- assert r.status_int == 200
+ assert r.status_int == 204
assert r.body == b_('')
def test_multi_dot_extension(self):