You've already forked cpp-httplib
Make code sample compilable (#2207)
This commit is contained in:
11
README.md
11
README.md
@@ -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
|
||||||
|
Reference in New Issue
Block a user