| 61 | |
| 62 | |
| 63 | class Stream(object): |
| 64 | |
| 65 | def __init__(self, content): |
| 66 | self.content = io.BytesIO(content) |
| 67 | |
| 68 | @asyncio.coroutine |
| 69 | def read(self, size=None): |
| 70 | return self.content.read(size) |
| 71 | |
| 72 | def at_eof(self): |
| 73 | return self.content.tell() == len(self.content.getbuffer()) |
| 74 | |
| 75 | @asyncio.coroutine |
| 76 | def readline(self): |
| 77 | return self.content.readline() |
| 78 | |
| 79 | def unread_data(self, data): |
| 80 | self.content = io.BytesIO(data + self.content.read()) |
| 81 | |
| 82 | |
| 83 | class StreamWithShortenRead(Stream): |
no outgoing calls