//loop in another thread
auto loop = http::EventLoop::New();
loop->RunInBackground();
auto resp = http::Get("http://www.baidu.com", loop).SetTimeout(1000).Execute();
printf("%d:%lu\n", resp.GetResponseCode(), resp.GetBody().length);
//callback
http::Get("http://www.baidu.com")
.AddHeader("Connection", "keep-alive")
.SetTimeout(1000)
.Execute([](http::Response&& r) {
printf("%d:%lu\n", r.GetResponseCode(), r.GetBody().length);
});
//promise
std::promise<http::Response> p;
auto future = http::Get("http://www.baidu.com").SetTimeout(1000).Execute(p);
auto resp = future.get();
printf("%d:%lu\n", resp.GetResponseCode(), resp.GetBody().length);
-
Notifications
You must be signed in to change notification settings - Fork 0
user friendly libevent http api
License
thinkiny/libevent_http
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
user friendly libevent http api
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published