Fixed build errors with some examples
This commit is contained in:
parent
b9a9df4d73
commit
66f698fab6
@ -14,13 +14,12 @@ using namespace std;
|
|||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||||
httplib::url::Options options;
|
auto res = httplib::Client2("https://localhost:8080")
|
||||||
options.ca_cert_file_path = CA_CERT_FILE;
|
.set_ca_cert_path(CA_CERT_FILE)
|
||||||
// options.server_certificate_verification = true;
|
// .enable_server_certificate_verification(true)
|
||||||
|
.Get("/hi");
|
||||||
auto res = httplib::url::Get("https://localhost:8080/hi", options);
|
|
||||||
#else
|
#else
|
||||||
auto res = httplib::url::Get("http://localhost:8080/hi");
|
auto res = httplib::Client2("http://localhost:8080").Get("/hi");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
|
@ -80,15 +80,19 @@ int main(void) {
|
|||||||
svr.Get("/event1", [&](const Request & /*req*/, Response &res) {
|
svr.Get("/event1", [&](const Request & /*req*/, Response &res) {
|
||||||
cout << "connected to event1..." << endl;
|
cout << "connected to event1..." << endl;
|
||||||
res.set_header("Content-Type", "text/event-stream");
|
res.set_header("Content-Type", "text/event-stream");
|
||||||
res.set_chunked_content_provider(
|
res.set_chunked_content_provider([&](size_t /*offset*/, DataSink &sink) {
|
||||||
[&](uint64_t /*offset*/, DataSink &sink) { ed.wait_event(&sink); });
|
ed.wait_event(&sink);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
svr.Get("/event2", [&](const Request & /*req*/, Response &res) {
|
svr.Get("/event2", [&](const Request & /*req*/, Response &res) {
|
||||||
cout << "connected to event2..." << endl;
|
cout << "connected to event2..." << endl;
|
||||||
res.set_header("Content-Type", "text/event-stream");
|
res.set_header("Content-Type", "text/event-stream");
|
||||||
res.set_chunked_content_provider(
|
res.set_chunked_content_provider([&](size_t /*offset*/, DataSink &sink) {
|
||||||
[&](uint64_t /*offset*/, DataSink &sink) { ed.wait_event(&sink); });
|
ed.wait_event(&sink);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
thread t([&] {
|
thread t([&] {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user