| 98 | return rval |
| 99 | |
| 100 | def _convert_to_bytes(self, mixed_buffer): |
| 101 | # Take a list of mixed str/bytes and convert it |
| 102 | # all into a single bytestring. |
| 103 | # Any str will be encoded as utf-8. |
| 104 | bytes_buffer = [] |
| 105 | for chunk in mixed_buffer: |
| 106 | if isinstance(chunk, str): |
| 107 | bytes_buffer.append(chunk.encode('utf-8')) |
| 108 | else: |
| 109 | bytes_buffer.append(chunk) |
| 110 | msg = b"\r\n".join(bytes_buffer) |
| 111 | return msg |
| 112 | |
| 113 | def _send_output(self, message_body=None, *args, **kwargs): |
| 114 | self._buffer.extend((b"", b"")) |