TEST_F(HttpServerTest, get_200_OK) { TcpServer server(_ios); server.setFactory<TestConnectionHandler>(); error_code ec = server.bind(tcp::endpoint(tcp::v4(), 8787)); ASSERT_FALSE(ec); server.run(); std::thread svr_th([&](){ _ios.run(); }); io_service ios; HttpClient client(ios); HttpRequest req; HttpResponse resp; bool run = false; req.method(HttpRequest::GET).url("http://localhost:8787"); client.asyncRun(&req, &resp, [&](const error_code &ec, HttpResponse *resp) { EXPECT_FALSE(ec); run = true; EXPECT_EQ(200, resp->statusCode()); EXPECT_EQ(6, resp->contentLength()); EXPECT_EQ(std::string("melong"), resp->content()); }); ios.run(); EXPECT_TRUE(run); server.stop(); svr_th.join(); }