2018-12-31 20:04:05 +01:00
|
|
|
//
|
2018-12-31 23:02:34 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
|
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)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/net/HttpOutboundConnection.h"
|
|
|
|
#include "td/net/HttpQuery.h"
|
2018-08-15 14:41:42 +02:00
|
|
|
#include "td/net/SslStream.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-07-03 21:29:04 +02:00
|
|
|
#include "td/actor/actor.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/actor/PromiseFuture.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class Wget : public HttpOutboundConnection::Callback {
|
|
|
|
public:
|
|
|
|
explicit Wget(Promise<HttpQueryPtr> promise, string url, std::vector<std::pair<string, string>> headers = {},
|
2018-07-01 03:45:25 +02:00
|
|
|
int32 timeout_in = 10, int32 ttl = 3, bool prefer_ipv6 = false,
|
2018-08-15 14:41:42 +02:00
|
|
|
SslStream::VerifyPeer verify_peer = SslStream::VerifyPeer::On);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Status try_init();
|
|
|
|
void loop() override;
|
|
|
|
void handle(HttpQueryPtr result) override;
|
|
|
|
void on_connection_error(Status error) override;
|
|
|
|
void on_ok(HttpQueryPtr http_query_ptr);
|
|
|
|
void on_error(Status error);
|
|
|
|
|
|
|
|
void tear_down() override;
|
|
|
|
void start_up() override;
|
|
|
|
void timeout_expired() override;
|
|
|
|
|
|
|
|
Promise<HttpQueryPtr> promise_;
|
|
|
|
ActorOwn<HttpOutboundConnection> connection_;
|
|
|
|
string input_url_;
|
|
|
|
std::vector<std::pair<string, string>> headers_;
|
|
|
|
int32 timeout_in_;
|
|
|
|
int32 ttl_;
|
2018-07-01 03:45:25 +02:00
|
|
|
bool prefer_ipv6_ = false;
|
2018-08-15 14:41:42 +02:00
|
|
|
SslStream::VerifyPeer verify_peer_;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|