summaryrefslogtreecommitdiff
path: root/cherrypy/_cprequest.py
diff options
context:
space:
mode:
Diffstat (limited to 'cherrypy/_cprequest.py')
-rw-r--r--cherrypy/_cprequest.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/cherrypy/_cprequest.py b/cherrypy/_cprequest.py
index f9943ff7..bde09891 100644
--- a/cherrypy/_cprequest.py
+++ b/cherrypy/_cprequest.py
@@ -2,9 +2,12 @@ import sys
import time
import uuid
+
import six
from six.moves.http_cookies import SimpleCookie, CookieError
+from more_itertools.recipes import consume
+
import cherrypy
from cherrypy._cpcompat import text_or_bytes, ntob
from cherrypy import _cpreqbody
@@ -879,6 +882,14 @@ class Response(object):
self.body = newbody
return newbody
+ def _flush_body(self):
+ """
+ Discard self.body but consume any generator such that
+ any finalization can occur, such as is required by
+ caching.tee_output().
+ """
+ consume(iter(self.body))
+
def finalize(self):
"""Transform headers (and cookies) into self.header_list. (Core)"""
try:
@@ -903,6 +914,7 @@ class Response(object):
# and 304 (not modified) responses MUST NOT
# include a message-body."
dict.pop(headers, 'Content-Length', None)
+ self._flush_body()
self.body = b''
else:
# Responses which are not streamed should have a Content-Length,