Permalink
Browse files

Removed a warning that was displayed for HEAD requests.

  • Loading branch information...
1 parent 563c950 commit d4ca0dfa47beb66343a52e212f00fb28b2f6a085 @madjar madjar committed Nov 24, 2012
Showing with 18 additions and 5 deletions.
  1. +6 −5 waitress/task.py
  2. +12 −0 waitress/tests/test_task.py
View
@@ -418,11 +418,12 @@ def start_response(status, headers, exc_info=None):
# waiting for more data when there are too few bytes
# to service content-length
self.close_on_finish = True
- self.logger.warning(
- 'application returned too few bytes (%s) '
- 'for specified Content-Length (%s) via app_iter' % (
- self.content_bytes_written, cl),
- )
+ if self.request.command != 'HEAD':
+ self.logger.warning(
+ 'application returned too few bytes (%s) '
+ 'for specified Content-Length (%s) via app_iter' % (
+ self.content_bytes_written, cl),
+ )
finally:
if hasattr(app_iter, 'close'):
app_iter.close()
@@ -457,6 +457,18 @@ def app(environ, start_response):
self.assertEqual(inst.close_on_finish, True)
self.assertEqual(len(inst.logger.logged), 1)
+ def test_execute_app_do_not_warn_on_head(self):
+ def app(environ, start_response):
+ start_response('200 OK', [('Content-Length', '3')])
+ return [b'']
+ inst = self._makeOne()
+ inst.request.command = 'HEAD'
+ inst.channel.server.application = app
+ inst.logger = DummyLogger()
+ inst.execute()
+ self.assertEqual(inst.close_on_finish, True)
+ self.assertEqual(len(inst.logger.logged), 0)
+
def test_execute_app_returns_closeable(self):
class closeable(list):
def close(self):

0 comments on commit d4ca0df

Please sign in to comment.