diff --git a/httplib.h b/httplib.h index 9bf9d64..ca29cc2 100644 --- a/httplib.h +++ b/httplib.h @@ -6309,7 +6309,7 @@ inline bool ClientImpl::send(Request &req, Response &res, Error &error) { if (is_ssl()) { auto &scli = static_cast(*this); if (!proxy_host_.empty() && proxy_port_ != -1) { - bool success = false; + auto success = false; if (!scli.connect_with_proxy(socket_, res, success, error)) { return success; } @@ -7789,7 +7789,7 @@ inline bool SSLServer::process_and_close_socket(socket_t sock) { }, [](SSL * /*ssl2*/) { return true; }); - bool ret = false; + auto ret = false; if (ssl) { ret = detail::process_server_socket_ssl( svr_sock_, ssl, sock, keep_alive_max_count_, keep_alive_timeout_sec_, diff --git a/test/test.cc b/test/test.cc index 83d7997..298aa8e 100644 --- a/test/test.cc +++ b/test/test.cc @@ -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) {