diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2018-08-17 14:34:39 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2018-08-17 14:34:39 -0400 |
commit | efa9e3722a763bb5a2c51199d6c0d9f90df8f90c (patch) | |
tree | 38cf94c0d477508e6ac17cf01c3d9eb8ba2af983 | |
parent | 7fdd6d3b98c88cab5bc606bce76cb4a85ae22e41 (diff) | |
download | cherrypy-git-efa9e3722a763bb5a2c51199d6c0d9f90df8f90c.tar.gz |
self.body is always iterable due to the ResponseBody descriptor. And PY3 will already raise a TypeError if you try to join not bytes, so simplify collapse_body.
-rw-r--r-- | cherrypy/_cprequest.py | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/cherrypy/_cprequest.py b/cherrypy/_cprequest.py index bde09891..739ad2e8 100644 --- a/cherrypy/_cprequest.py +++ b/cherrypy/_cprequest.py @@ -868,19 +868,9 @@ class Response(object): def collapse_body(self): """Collapse self.body to a single string; replace it and return it.""" - if isinstance(self.body, text_or_bytes): - return self.body - - newbody = [] - for chunk in self.body: - if six.PY3 and not isinstance(chunk, bytes): - raise TypeError("Chunk %s is not of type 'bytes'." % - repr(chunk)) - newbody.append(chunk) - newbody = b''.join(newbody) - - self.body = newbody - return newbody + new_body = b''.join(self.body) + self.body = new_body + return new_body def _flush_body(self): """ |