Skip to content

Commit c2a45c2

Browse files
committed
Add test to verify dangling ref fix
1 parent f46df5b commit c2a45c2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/test.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,27 @@ TEST(RangeTest, FromHTTPBin_Online) {
13311331
}
13321332
}
13331333

1334+
TEST(GetAddrInfoDanglingRefTest, LongTimeout) {
1335+
auto host = "unresolvableaddress.local";
1336+
auto path = std::string{"/"};
1337+
1338+
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
1339+
auto port = 443;
1340+
SSLClient cli(host, port);
1341+
#else
1342+
auto port = 80;
1343+
Client cli(host, port);
1344+
#endif
1345+
cli.set_connection_timeout(1);
1346+
1347+
{
1348+
auto res = cli.Get(path);
1349+
ASSERT_FALSE(res);
1350+
}
1351+
1352+
std::this_thread::sleep_for(8s);
1353+
}
1354+
13341355
TEST(ConnectionErrorTest, InvalidHost) {
13351356
auto host = "-abcde.com";
13361357

0 commit comments

Comments
 (0)