2020-11-03 17:34:10 +01:00
|
|
|
//
|
2021-01-06 15:24:16 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
|
2020-11-03 17:34:10 +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)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "telegram-bot-api/ClientManager.h"
|
|
|
|
|
|
|
|
#include "td/net/HttpInboundConnection.h"
|
|
|
|
#include "td/net/HttpQuery.h"
|
|
|
|
|
2022-01-25 16:18:44 +01:00
|
|
|
#include "td/actor/actor.h"
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
#include "td/utils/buffer.h"
|
2022-06-30 18:59:30 +02:00
|
|
|
#include "td/utils/Status.h"
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
namespace telegram_bot_api {
|
|
|
|
|
2022-01-25 16:18:44 +01:00
|
|
|
class HttpStatConnection final : public td::HttpInboundConnection::Callback {
|
2020-11-03 17:34:10 +01:00
|
|
|
public:
|
|
|
|
explicit HttpStatConnection(td::ActorId<ClientManager> client_manager) : client_manager_(client_manager) {
|
|
|
|
}
|
|
|
|
|
2022-06-30 18:59:30 +02:00
|
|
|
void handle(td::unique_ptr<td::HttpQuery> http_query, td::ActorOwn<td::HttpInboundConnection> connection) final;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
private:
|
2021-01-24 18:09:53 +01:00
|
|
|
bool as_json_;
|
2020-11-03 17:34:10 +01:00
|
|
|
td::ActorId<ClientManager> client_manager_;
|
|
|
|
td::ActorOwn<td::HttpInboundConnection> connection_;
|
|
|
|
|
2022-06-30 18:59:30 +02:00
|
|
|
void on_result(td::Result<td::BufferSlice> result);
|
|
|
|
|
2022-01-25 16:18:44 +01:00
|
|
|
void hangup() final {
|
2020-11-03 17:34:10 +01:00
|
|
|
connection_.release();
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace telegram_bot_api
|