1
0
mirror of synced 2025-10-20 02:29:24 +03:00

Make code sample compilable (#2207)

This commit is contained in:
Thomas Beutlich
2025-08-14 12:57:39 +02:00
committed by GitHub
parent dffce89514
commit fbd6ce7a3f

View File

@@ -98,34 +98,33 @@ httplib::Client cli("https://example.com");
auto res = cli.Get("/"); auto res = cli.Get("/");
if (!res) { if (!res) {
// Check the error type // Check the error type
auto err = res.error(); const auto err = res.error();
switch (err) { switch (err) {
case httplib::Error::SSLConnection: case httplib::Error::SSLConnection:
std::cout << "SSL connection failed, SSL error: " std::cout << "SSL connection failed, SSL error: "
<< res->ssl_error() << std::endl; << res.ssl_error() << std::endl;
break; break;
case httplib::Error::SSLLoadingCerts: case httplib::Error::SSLLoadingCerts:
std::cout << "SSL cert loading failed, OpenSSL error: " std::cout << "SSL cert loading failed, OpenSSL error: "
<< std::hex << res->ssl_openssl_error() << std::endl; << std::hex << res.ssl_openssl_error() << std::endl;
break; break;
case httplib::Error::SSLServerVerification: case httplib::Error::SSLServerVerification:
std::cout << "SSL verification failed, X509 error: " std::cout << "SSL verification failed, X509 error: "
<< res->ssl_openssl_error() << std::endl; << res.ssl_openssl_error() << std::endl;
break; break;
case httplib::Error::SSLServerHostnameVerification: case httplib::Error::SSLServerHostnameVerification:
std::cout << "SSL hostname verification failed, X509 error: " std::cout << "SSL hostname verification failed, X509 error: "
<< res->ssl_openssl_error() << std::endl; << res.ssl_openssl_error() << std::endl;
break; break;
default: default:
std::cout << "HTTP error: " << httplib::to_string(err) << std::endl; std::cout << "HTTP error: " << httplib::to_string(err) << std::endl;
} }
} }
}
``` ```
Server Server