MCPcopy Create free account
hub / github.com/TelegramMessenger/cocoon / run_http_request

Method run_http_request

runners/client/ClientRunner.cpp:24–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 */
23
24void ClientRunner::run_http_request(http::HttpCallback::RequestType request_type,
25 std::vector<std::pair<std::string, std::string>> headers, std::string path,
26 std::vector<std::pair<std::string, std::string>> args, std::string body,
27 std::unique_ptr<http::HttpRequestCallback> answer_callback) {
28 auto proxy_target = get_ready_proxy_target();
29 if (!proxy_target || !proxy_target->is_ready()) {
30 return http_send_static_answer(503 /* service unavailable */, "no working proxy connections",
31 std::move(answer_callback));
32 }
33
34 auto connection = get_connection(proxy_target->connection_id());
35 if (!connection || !connection->is_ready()) {
36 return http_send_static_answer(503 /* service unavailable */, "no working proxy connections",
37 std::move(answer_callback));
38 }
39
40 td::Bits256 request_id;
41 td::Random::secure_bytes(request_id.as_slice());
42
43 auto proxy_conn = static_cast<ClientProxyConnection *>(connection);
44 auto proxy = proxy_conn->proxy();
45
46 proxy->request_started();
47 auto active_config_version = runner_config()->root_contract_config->version();
48 auto req = td::actor::create_actor<ClientRunningRequest>(
49 PSTRING() << "request_" << request_id.to_hex(), request_id, request_type, std::move(headers),
50 std::move(path), std::move(args), std::move(body), std::move(answer_callback), proxy,
51 connection->connection_id(), proxy_conn->proto_version(), active_config_version, actor_id(this))
52 .release();
53 running_queries_.emplace(request_id, req);
54}
55
56void ClientRunner::run_get_models_request(std::unique_ptr<http::HttpRequestCallback> answer_callback) {
57 auto proxy_target = get_ready_proxy_target();

Callers

nothing calls this directly

Calls 6

as_sliceMethod · 0.80
request_startedMethod · 0.80
versionMethod · 0.80
is_readyMethod · 0.45
connection_idMethod · 0.45
proto_versionMethod · 0.45

Tested by

no test coverage detected