2018-10-18 07:54:57 +00:00
|
|
|
#include <drogon/drogon.h>
|
2018-07-24 09:24:23 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <future>
|
|
|
|
int main()
|
|
|
|
{
|
2019-02-02 03:34:00 +00:00
|
|
|
trantor::Logger::setLogLevel(trantor::Logger::TRACE);
|
2018-09-10 07:50:44 +00:00
|
|
|
{
|
2019-02-02 03:34:00 +00:00
|
|
|
int count = 0;
|
2018-11-17 09:33:05 +00:00
|
|
|
auto client = HttpClient::newHttpClient("http://www.baidu.com");
|
2018-11-09 07:21:53 +00:00
|
|
|
auto req = HttpRequest::newHttpRequest();
|
|
|
|
req->setMethod(drogon::Get);
|
|
|
|
req->setPath("/s");
|
|
|
|
req->setParameter("wd", "weixin");
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
{
|
2019-02-02 03:34:00 +00:00
|
|
|
client->sendRequest(req, [&count](ReqResult result, const HttpResponsePtr &response) {
|
2018-11-09 07:21:53 +00:00
|
|
|
std::cout << "receive response!" << std::endl;
|
|
|
|
//auto headers=response.
|
|
|
|
count++;
|
2018-11-15 14:00:23 +00:00
|
|
|
std::cout << response->getBody() << std::endl;
|
2019-01-02 08:13:36 +00:00
|
|
|
auto cookies = response->cookies();
|
2019-01-21 09:32:49 +00:00
|
|
|
for (auto const &cookie : cookies)
|
2019-01-02 08:13:36 +00:00
|
|
|
{
|
|
|
|
std::cout << cookie.first << "=" << cookie.second.value() << ":domain=" << cookie.second.domain() << std::endl;
|
|
|
|
}
|
2018-11-09 07:21:53 +00:00
|
|
|
std::cout << "count=" << count << std::endl;
|
|
|
|
});
|
|
|
|
}
|
2018-07-24 09:24:23 +00:00
|
|
|
}
|
2018-09-10 07:50:44 +00:00
|
|
|
|
2018-11-09 07:21:53 +00:00
|
|
|
app().run();
|
2018-10-18 07:54:57 +00:00
|
|
|
}
|