simplecli.cc 548 B

1234567891011121314151617181920212223242526272829
  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. using namespace std;
  10. int main(void) {
  11. #ifdef CPPHTTPLIB_OPENSSL_SUPPORT
  12. auto scheme_host_port = "https://localhost:8080";
  13. #else
  14. auto scheme_host_port = "http://localhost:8080";
  15. #endif
  16. auto res = httplib::Client2(scheme_host_port).Get("/hi");
  17. if (res) {
  18. cout << res->status << endl;
  19. cout << res->get_header_value("Content-Type") << endl;
  20. cout << res->body << endl;
  21. }
  22. return 0;
  23. }