simplecli.cc 653 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // simplecli.cc
  3. //
  4. // Copyright (c) 2019 Yuji Hirose. All rights reserved.
  5. // MIT License
  6. //
  7. #include <httplib.h>
  8. #include <iostream>
  9. #define CA_CERT_FILE "./ca-bundle.crt"
  10. using namespace std;
  11. int main(void) {
  12. #ifdef CPPHTTPLIB_OPENSSL_SUPPORT
  13. auto res = httplib::Client2("https://localhost:8080")
  14. .set_ca_cert_path(CA_CERT_FILE)
  15. // .enable_server_certificate_verification(true)
  16. .Get("/hi");
  17. #else
  18. auto res = httplib::Client2("http://localhost:8080").Get("/hi");
  19. #endif
  20. if (res) {
  21. cout << res->status << endl;
  22. cout << res->get_header_value("Content-Type") << endl;
  23. cout << res->body << endl;
  24. }
  25. return 0;
  26. }