2018-10-18 07:54:57 +00:00
|
|
|
#include <drogon/drogon.h>
|
2018-07-24 09:24:23 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <future>
|
2019-02-02 05:45:40 +00:00
|
|
|
|
|
|
|
using namespace drogon;
|
|
|
|
|
2018-07-24 09:24:23 +00:00
|
|
|
int main()
|
|
|
|
{
|
2020-01-25 03:58:20 +00:00
|
|
|
trantor::Logger::setLogLevel(trantor::Logger::kTrace);
|
2018-09-10 07:50:44 +00:00
|
|
|
{
|
2019-02-02 03:34:00 +00:00
|
|
|
int count = 0;
|
2020-06-16 12:36:31 +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");
|
2020-06-16 12:36:31 +00:00
|
|
|
req->setParameter("wd", "wx");
|
|
|
|
req->setParameter("oq", "wx");
|
2018-11-09 07:21:53 +00:00
|
|
|
|
2019-11-21 03:27:47 +00:00
|
|
|
for (int i = 0; i < 10; ++i)
|
2018-11-09 07:21:53 +00:00
|
|
|
{
|
2019-05-18 12:39:57 +00:00
|
|
|
client->sendRequest(
|
|
|
|
req,
|
|
|
|
[&count](ReqResult result, const HttpResponsePtr &response) {
|
|
|
|
std::cout << "receive response!" << std::endl;
|
|
|
|
// auto headers=response.
|
2019-11-21 03:27:47 +00:00
|
|
|
++count;
|
2019-05-18 12:39:57 +00:00
|
|
|
std::cout << response->getBody() << std::endl;
|
|
|
|
auto cookies = response->cookies();
|
|
|
|
for (auto const &cookie : cookies)
|
|
|
|
{
|
|
|
|
std::cout << cookie.first << "="
|
|
|
|
<< cookie.second.value()
|
|
|
|
<< ":domain=" << cookie.second.domain()
|
|
|
|
<< std::endl;
|
|
|
|
}
|
|
|
|
std::cout << "count=" << count << std::endl;
|
|
|
|
});
|
2018-11-09 07:21:53 +00:00
|
|
|
}
|
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
|
|
|
}
|