client.cc 559 B

123456789101112131415161718192021222324252627282930
  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. #ifdef CPPHTTPLIB_OPENSSL_SUPPORT
  12. httplib::SSLClient cli("localhost", 8080);
  13. #else
  14. httplib::Client cli("localhost", 8080);
  15. #endif
  16. auto res = cli.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. }
  24. // vim: et ts=4 sw=4 cin cino={1s ff=unix