| 77 | |
| 78 | |
| 79 | class CapServer(TCPServer): |
| 80 | @gen.coroutine |
| 81 | def handle_stream(self, stream, address): |
| 82 | data = yield stream.read_until(b"\n") |
| 83 | data = to_unicode(data) |
| 84 | if data == data.upper(): |
| 85 | stream.write(b"error\talready capitalized\n") |
| 86 | else: |
| 87 | # data already has \n |
| 88 | stream.write(utf8("ok\t%s" % data.upper())) |
| 89 | stream.close() |
| 90 | |
| 91 | |
| 92 | class CapError(Exception): |