Skip to content

Commit

Permalink
fix mishandling of controllers returning an iter evaluating to False …
Browse files Browse the repository at this point in the history
…(such as

an empty list, which we return for HEAD requests)
fixes #507
thanks mvtellingen, Petr Kobalicek

--HG--
branch : trunk
  • Loading branch information
pjenvey committed Sep 17, 2008
1 parent 3796a2a commit 629dddc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pylons/wsgiapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __call__(self, environ, start_response):
log.debug("Transforming legacy Response object into WSGI "
"response")
return response(environ, start_response)
elif response:
elif response is not None:
return response

raise Exception("No content returned by controller (Did you remember "
Expand Down
6 changes: 6 additions & 0 deletions tests/test_units/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ def test_header_check(self):
assert resp.response.headers['Cache-Control'] == 'private'
assert resp.header('Content-Type') == 'text/plain'

def test_head(self):
self.baseenviron['pylons.routes_dict']['action'] = 'header_check'
resp = self.app._gen_request('HEAD', '/')
assert '' == resp.body
assert resp.header('Content-Type') == 'text/plain'

def test_redirect(self):
self.baseenviron['pylons.routes_dict']['action'] = 'use_redirect'
resp = self.app.get('/', status=301)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ def test_post(self):
response = self.app.post(url_for(controller='/sample', action='test_only_post'),
params={'id':4})
assert 'It was a post' in response

def test_head(self):
response = self.app._gen_request('HEAD', url_for(controller='/sample'))
assert '' == response.body

0 comments on commit 629dddc

Please sign in to comment.