mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-17 10:59:39 +00:00
1 parent
92b4f53012
commit
4285d33992
2 files changed
+58
-5
No files matched your search
@@ -7366,6 +7366,48 @@ TEST(KeepAliveTest, SSLClientReconnectionPost) {
|
||||
ASSERT_TRUE(result);
|
||||
EXPECT_EQ(200, result->status);
|
||||
}
|
||||
|
||||
TEST(SNI_AutoDetectionTest, SNI_Logic) {
|
||||
{
|
||||
SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE);
|
||||
ASSERT_TRUE(svr.is_valid());
|
||||
|
||||
svr.Get("/sni", [&](const Request &req, Response &res) {
|
||||
std::string expected;
|
||||
if (req.ssl) {
|
||||
if (const char *sni =
|
||||
SSL_get_servername(req.ssl, TLSEXT_NAMETYPE_host_name)) {
|
||||
expected = sni;
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(expected, req.get_param_value("expected"));
|
||||
res.set_content("ok", "text/plain");
|
||||
});
|
||||
|
||||
auto listen_thread = std::thread([&svr] { svr.listen(HOST, PORT); });
|
||||
auto se = detail::scope_exit([&] {
|
||||
svr.stop();
|
||||
listen_thread.join();
|
||||
ASSERT_FALSE(svr.is_running());
|
||||
});
|
||||
|
||||
svr.wait_until_ready();
|
||||
|
||||
{
|
||||
SSLClient cli("localhost", PORT);
|
||||
cli.enable_server_certificate_verification(false);
|
||||
auto res = cli.Get("/sni?expected=localhost");
|
||||
ASSERT_TRUE(res);
|
||||
}
|
||||
|
||||
{
|
||||
SSLClient cli("::1", PORT);
|
||||
cli.enable_server_certificate_verification(false);
|
||||
auto res = cli.Get("/sni?expected=");
|
||||
ASSERT_TRUE(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(ClientProblemDetectionTest, ContentProvider) {
|
||||
|
||||
Reference in new issue
Block a user