simplecli.cc 685 B

123456789101112131415161718192021222324252627282930313233
  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. httplib::url::Options options;
  14. options.ca_cert_file_path = CA_CERT_FILE;
  15. // options.server_certificate_verification = true;
  16. auto res = httplib::url::Get("https://localhost:8080/hi", options);
  17. #else
  18. auto res = httplib::url::Get("http://localhost:8080/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. }