From 4922ae62e09cd01dbf4e0b40f2d4ab7ce78031e9 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 8 Jan 2020 17:42:55 +0300 Subject: [PATCH] Return back HttpQuery in get_simple_config_impl. GitOrigin-RevId: 391c0c8cdd74633e57bc0780e1060c561468417a --- td/telegram/ConfigManager.cpp | 17 +++++++++-------- tdnet/td/net/HttpQuery.h | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 931b2568..8649f2de 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -31,8 +31,8 @@ #include "td/mtproto/RawConnection.h" #include "td/mtproto/TransportType.h" -#if !TD_EMSCRIPTEN //FIXME #include "td/net/HttpQuery.h" +#if !TD_EMSCRIPTEN //FIXME #include "td/net/SslStream.h" #include "td/net/Wget.h" #endif @@ -55,6 +55,7 @@ #include "td/utils/tl_parsers.h" #include "td/utils/UInt.h" +#include #include #include @@ -199,10 +200,10 @@ Result decode_config(Slice input) { return std::move(config); } -template static ActorOwn<> get_simple_config_impl(Promise promise, int32 scheduler_id, string url, string host, std::vector> headers, bool prefer_ipv6, - F &&get_config, string content = string(), string content_type = string()) { + std::function(HttpQuery &)> get_config, + string content = string(), string content_type = string()) { VLOG(config_recoverer) << "Request simple config from " << url; #if TD_EMSCRIPTEN // FIXME return ActorOwn<>(); @@ -242,7 +243,7 @@ ActorOwn<> get_simple_config_azure(Promise promise, const Co const bool prefer_ipv6 = shared_config == nullptr ? false : shared_config->get_option_boolean("prefer_ipv6"); return get_simple_config_impl(std::move(promise), scheduler_id, std::move(url), "tcdnb.azureedge.net", {}, prefer_ipv6, - [](auto &http_query) -> Result { return http_query.content_.str(); }); + [](HttpQuery &http_query) -> Result { return http_query.content_.str(); }); } static ActorOwn<> get_simple_config_dns(Slice address, Slice host, Promise promise, @@ -252,7 +253,7 @@ static ActorOwn<> get_simple_config_dns(Slice address, Slice host, Promise Result { + auto get_config = [](HttpQuery &http_query) -> Result { TRY_RESULT(json, json_decode(http_query.content_)); if (json.type() != JsonValue::Type::Object) { return Status::Error("Expected JSON object"); @@ -320,7 +321,7 @@ ActorOwn<> get_simple_config_firebase_remote_config(Promise "https://firebaseremoteconfig.googleapis.com/v1/projects/peak-vista-421/namespaces/" "firebase:fetch?key=AIzaSyC2-kAkpDsroixRXw-sTw-Wfqo4NxjMwwM"; const bool prefer_ipv6 = shared_config == nullptr ? false : shared_config->get_option_boolean("prefer_ipv6"); - auto get_config = [](auto &http_query) -> Result { + auto get_config = [](HttpQuery &http_query) -> Result { TRY_RESULT(json, json_decode(http_query.get_arg("entries"))); if (json.type() != JsonValue::Type::Object) { return Status::Error("Expected JSON object"); @@ -342,7 +343,7 @@ ActorOwn<> get_simple_config_firebase_realtime(Promise promi string url = "https://reserve-5a846.firebaseio.com/ipconfigv3.json"; const bool prefer_ipv6 = shared_config == nullptr ? false : shared_config->get_option_boolean("prefer_ipv6"); - auto get_config = [](auto &http_query) -> Result { + auto get_config = [](HttpQuery &http_query) -> Result { return http_query.get_arg("content").str(); }; return get_simple_config_impl(std::move(promise), scheduler_id, std::move(url), "reserve-5a846.firebaseio.com", {}, @@ -358,7 +359,7 @@ ActorOwn<> get_simple_config_firebase_firestore(Promise prom string url = "https://www.google.com/v1/projects/reserve-5a846/databases/(default)/documents/ipconfig/v3"; const bool prefer_ipv6 = shared_config == nullptr ? false : shared_config->get_option_boolean("prefer_ipv6"); - auto get_config = [](auto &http_query) -> Result { + auto get_config = [](HttpQuery &http_query) -> Result { TRY_RESULT(json, json_decode(http_query.get_arg("fields"))); if (json.type() != JsonValue::Type::Object) { return Status::Error("Expected JSON object"); diff --git a/tdnet/td/net/HttpQuery.h b/tdnet/td/net/HttpQuery.h index b037d47d..e73ef605 100644 --- a/tdnet/td/net/HttpQuery.h +++ b/tdnet/td/net/HttpQuery.h @@ -23,9 +23,9 @@ class HttpQuery { std::vector container_; Type type_ = Type::EMPTY; + int32 code_ = 0; MutableSlice url_path_; std::vector> args_; - int code_ = 0; MutableSlice reason_; bool keep_alive_ = true;