client.cc 531 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. using namespace httplib;
  11. int main(void)
  12. {
  13. const char* hi = "/hi";
  14. Client cli("localhost", 8080);
  15. auto res = cli.get(hi);
  16. if (res) {
  17. cout << res->status << endl;
  18. cout << res->get_header_value("Content-Type") << endl;
  19. cout << res->body << endl;
  20. }
  21. return 0;
  22. }
  23. // vim: et ts=4 sw=4 cin cino={1s ff=unix