simplecli.cc 583 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. if (auto res = httplib::Client(scheme_host_port).Get("/hi")) {
  17. cout << res->status << endl;
  18. cout << res->get_header_value("Content-Type") << endl;
  19. cout << res->body << endl;
  20. } else {
  21. cout << res.error() << endl;
  22. }
  23. return 0;
  24. }