def _get_body(self, resp, wsgi_file_wrapper=None):

        body = resp.body
        if body is not None:
            if not isinstance(body, bytes):
                body = body.encode('utf-8')

            return [body], len(body)

        data = resp.data
        if data is not None:
            return [data], len(data)

        stream = resp.stream
        if stream is not None:
            # NOTE(kgriffs): Heuristic to quickly check if stream is
            # file-like. Not perfect, but should be good enough until
            # proven otherwise.
            if hasattr(stream, 'read'):
                if wsgi_file_wrapper is not None:
                    # TODO(kgriffs): Make block size configurable at the
                    # global level, pending experimentation to see how
                    # useful that would be. See also the discussion on
                    # this GitHub PR: http://goo.gl/XGrtDz
                    iterable = wsgi_file_wrapper(stream,
                                                 self._STREAM_BLOCK_SIZE)
                else:
                    iterable = iter(
                        lambda: stream.read(self._STREAM_BLOCK_SIZE),
                        b''
                    )
            else:
                iterable = stream

            # NOTE(kgriffs): If resp.stream_len is None, content_length
            # will be as well; the caller of _get_body must handle this
            # case by not setting the Content-Length header.
            return iterable, resp.stream_len

        return [], 0
Converts resp content into an iterable as required by PEP 333
dataset/ETHPy150Open falconry/falcon/falcon/api.py/API._get_body