|
|
@@ -4026,7 +4026,7 @@ TEST(KeepAliveTest, ReadTimeout) {
|
|
|
cli.set_read_timeout(std::chrono::seconds(1));
|
|
|
|
|
|
auto resa = cli.Get("/a");
|
|
|
- ASSERT_TRUE(!resa);
|
|
|
+ ASSERT_FALSE(resa);
|
|
|
EXPECT_EQ(Error::Read, resa.error());
|
|
|
|
|
|
auto resb = cli.Get("/b");
|
|
|
@@ -4040,33 +4040,31 @@ TEST(KeepAliveTest, ReadTimeout) {
|
|
|
}
|
|
|
|
|
|
TEST(KeepAliveTest, Issue1041) {
|
|
|
- const auto resourcePath = "/hi";
|
|
|
-
|
|
|
Server svr;
|
|
|
svr.set_keep_alive_timeout(3);
|
|
|
|
|
|
- svr.Get(resourcePath, [](const httplib::Request &, httplib::Response &res) {
|
|
|
+ svr.Get("/hi", [](const httplib::Request &, httplib::Response &res) {
|
|
|
res.set_content("Hello World!", "text/plain");
|
|
|
});
|
|
|
|
|
|
- auto a2 = std::async(std::launch::async, [&svr] { svr.listen(HOST, PORT); });
|
|
|
+ auto f = std::async(std::launch::async, [&svr] { svr.listen(HOST, PORT); });
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
|
|
|
|
|
Client cli(HOST, PORT);
|
|
|
cli.set_keep_alive(true);
|
|
|
|
|
|
- auto result = cli.Get(resourcePath);
|
|
|
+ auto result = cli.Get("/hi");
|
|
|
ASSERT_TRUE(result);
|
|
|
EXPECT_EQ(200, result->status);
|
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(5));
|
|
|
|
|
|
- result = cli.Get(resourcePath);
|
|
|
+ result = cli.Get("/hi");
|
|
|
ASSERT_TRUE(result);
|
|
|
EXPECT_EQ(200, result->status);
|
|
|
|
|
|
svr.stop();
|
|
|
- a2.wait();
|
|
|
+ f.wait();
|
|
|
}
|
|
|
|
|
|
TEST(ClientProblemDetectionTest, ContentProvider) {
|