client.cc 583 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // client.cc
  3. //
  4. // Copyright (c) 2012 Yuji Hirose. All rights reserved.
  5. // The Boost Software License 1.0
  6. //
  7. #include <httplib.h>
  8. #include <iostream>
  9. using namespace std;
  10. int main(void)
  11. {
  12. #ifdef CPPHTTPLIB_OPENSSL_SUPPORT
  13. httplib::SSLClient cli("localhost", 8080);
  14. #else
  15. httplib::Client cli("localhost", 8080);
  16. #endif
  17. auto res = cli.Get("/hi");
  18. if (res) {
  19. cout << res->status << endl;
  20. cout << res->get_header_value("Content-Type") << endl;
  21. cout << res->body << endl;
  22. }
  23. return 0;
  24. }
  25. // vim: et ts=4 sw=4 cin cino={1s ff=unix