1.源码实现
#include <iostream>
#include <httplib.h>
using namespace std;
int main(void)
{
httplib::Client cli("localhost", 18080);
auto res = cli.Get("/");
if(res)
{
cout << res->status << endl;
cout << res->get_header_value("Content-Type") << endl;
cout << res->body << endl;
}
return 0;
}
2.编译源码
$ g++ -o client client.cpp -I$HOME/local/include -std=c++11
3.运行程序
$ ./client
网友评论