def test_basic(self): socket_obj = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) stream = IOStream(socket_obj) yield stream.connect(('127.0.0.1', self.get_http_port())) yield stream.write(b'GET / HTTP/1.0\r\n\r\n') headers = yield stream.read_until(b'\r\n\r\n') self.assertIn(b'OK', headers) body_1 = yield stream.read_until(b' ') body_2 = yield stream.read_until_close() self.assertEqual(b'hello world!', body_1 + body_2) self.assertTrue(stream.closed)