2018-12-31 20:04:05 +01:00
|
|
|
//
|
2022-01-01 01:35:39 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
2021-09-18 23:47:05 +02:00
|
|
|
#include "td/net/HttpQuery.h"
|
|
|
|
#include "td/net/Wget.h"
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/actor/actor.h"
|
2020-11-23 01:24:36 +01:00
|
|
|
#include "td/actor/ConcurrentScheduler.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-07-01 03:45:25 +02:00
|
|
|
#include "td/utils/common.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/logging.h"
|
2022-06-27 12:30:18 +02:00
|
|
|
#include "td/utils/Promise.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2018-08-15 14:41:42 +02:00
|
|
|
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(DEBUG));
|
2018-12-31 20:04:05 +01:00
|
|
|
td::VERBOSITY_NAME(fd) = VERBOSITY_NAME(INFO);
|
|
|
|
|
2020-05-16 14:57:37 +02:00
|
|
|
td::string url = (argc > 1 ? argv[1] : "https://telegram.org");
|
2018-07-01 03:45:25 +02:00
|
|
|
auto timeout = 10;
|
|
|
|
auto ttl = 3;
|
2020-05-16 14:57:37 +02:00
|
|
|
auto prefer_ipv6 = (argc > 2 && td::string(argv[2]) == "-6");
|
2018-09-27 03:19:03 +02:00
|
|
|
auto scheduler = td::make_unique<td::ConcurrentScheduler>();
|
2018-12-31 20:04:05 +01:00
|
|
|
scheduler->init(0);
|
|
|
|
scheduler
|
2019-06-17 18:12:54 +02:00
|
|
|
->create_actor_unsafe<td::Wget>(0, "Client",
|
|
|
|
td::PromiseCreator::lambda([](td::Result<td::unique_ptr<td::HttpQuery>> res) {
|
2020-05-16 17:43:49 +02:00
|
|
|
if (res.is_error()) {
|
|
|
|
LOG(FATAL) << res.error();
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
LOG(ERROR) << *res.ok();
|
|
|
|
td::Scheduler::instance()->finish();
|
|
|
|
}),
|
2018-07-01 03:45:25 +02:00
|
|
|
url, td::Auto(), timeout, ttl, prefer_ipv6)
|
2018-12-31 20:04:05 +01:00
|
|
|
.release();
|
|
|
|
scheduler->start();
|
|
|
|
while (scheduler->run_main(10)) {
|
|
|
|
// empty
|
|
|
|
}
|
|
|
|
scheduler->finish();
|
|
|
|
}
|