Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Commit cdaa5c4

Browse files
committed
Code cleanup
1 parent bab5c0e commit cdaa5c4

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

httplib.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6309,7 +6309,7 @@ inline bool ClientImpl::send(Request &req, Response &res, Error &error) {
63096309
if (is_ssl()) {
63106310
auto &scli = static_cast<SSLClient &>(*this);
63116311
if (!proxy_host_.empty() && proxy_port_ != -1) {
6312-
bool success = false;
6312+
auto success = false;
63136313
if (!scli.connect_with_proxy(socket_, res, success, error)) {
63146314
return success;
63156315
}
@@ -7789,7 +7789,7 @@ inline bool SSLServer::process_and_close_socket(socket_t sock) {
77897789
},
77907790
[](SSL * /*ssl2*/) { return true; });
77917791

7792-
bool ret = false;
7792+
auto ret = false;
77937793
if (ssl) {
77947794
ret = detail::process_server_socket_ssl(
77957795
svr_sock_, ssl, sock, keep_alive_max_count_, keep_alive_timeout_sec_,

test/test.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4026,7 +4026,7 @@ TEST(KeepAliveTest, ReadTimeout) {
40264026
cli.set_read_timeout(std::chrono::seconds(1));
40274027

40284028
auto resa = cli.Get("/a");
4029-
ASSERT_TRUE(!resa);
4029+
ASSERT_FALSE(resa);
40304030
EXPECT_EQ(Error::Read, resa.error());
40314031

40324032
auto resb = cli.Get("/b");
@@ -4040,33 +4040,31 @@ TEST(KeepAliveTest, ReadTimeout) {
40404040
}
40414041

40424042
TEST(KeepAliveTest, Issue1041) {
4043-
const auto resourcePath = "/hi";
4044-
40454043
Server svr;
40464044
svr.set_keep_alive_timeout(3);
40474045

4048-
svr.Get(resourcePath, [](const httplib::Request &, httplib::Response &res) {
4046+
svr.Get("/hi", [](const httplib::Request &, httplib::Response &res) {
40494047
res.set_content("Hello World!", "text/plain");
40504048
});
40514049

4052-
auto a2 = std::async(std::launch::async, [&svr] { svr.listen(HOST, PORT); });
4050+
auto f = std::async(std::launch::async, [&svr] { svr.listen(HOST, PORT); });
40534051
std::this_thread::sleep_for(std::chrono::milliseconds(200));
40544052

40554053
Client cli(HOST, PORT);
40564054
cli.set_keep_alive(true);
40574055

4058-
auto result = cli.Get(resourcePath);
4056+
auto result = cli.Get("/hi");
40594057
ASSERT_TRUE(result);
40604058
EXPECT_EQ(200, result->status);
40614059

40624060
std::this_thread::sleep_for(std::chrono::seconds(5));
40634061

4064-
result = cli.Get(resourcePath);
4062+
result = cli.Get("/hi");
40654063
ASSERT_TRUE(result);
40664064
EXPECT_EQ(200, result->status);
40674065

40684066
svr.stop();
4069-
a2.wait();
4067+
f.wait();
40704068
}
40714069

40724070
TEST(ClientProblemDetectionTest, ContentProvider) {

0 commit comments

Comments
 (0)