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)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/net/HttpFile.h"
|
|
|
|
|
|
|
|
#include "td/utils/buffer.h"
|
|
|
|
#include "td/utils/common.h"
|
2020-07-13 20:49:07 +02:00
|
|
|
#include "td/utils/port/IPAddress.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/Slice.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class HttpQuery {
|
|
|
|
public:
|
2020-06-15 03:23:47 +02:00
|
|
|
enum class Type : int8 { Empty, Get, Post, Response };
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-06-26 01:24:13 +02:00
|
|
|
vector<BufferSlice> container_;
|
2020-06-15 03:23:47 +02:00
|
|
|
Type type_ = Type::Empty;
|
2020-01-08 15:42:55 +01:00
|
|
|
int32 code_ = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
MutableSlice url_path_;
|
2020-06-26 01:24:13 +02:00
|
|
|
vector<std::pair<MutableSlice, MutableSlice>> args_;
|
2018-12-31 20:04:05 +01:00
|
|
|
MutableSlice reason_;
|
|
|
|
|
2018-10-26 16:11:20 +02:00
|
|
|
bool keep_alive_ = true;
|
2020-06-26 01:24:13 +02:00
|
|
|
vector<std::pair<MutableSlice, MutableSlice>> headers_;
|
|
|
|
vector<HttpFile> files_;
|
2018-12-31 20:04:05 +01:00
|
|
|
MutableSlice content_;
|
|
|
|
|
2020-07-13 14:23:03 +02:00
|
|
|
IPAddress peer_address_;
|
|
|
|
|
2018-04-19 14:23:54 +02:00
|
|
|
Slice get_header(Slice key) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-04-19 14:23:54 +02:00
|
|
|
MutableSlice get_arg(Slice key) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-06-26 01:24:13 +02:00
|
|
|
vector<std::pair<string, string>> get_args() const;
|
2018-04-19 14:03:10 +02:00
|
|
|
|
|
|
|
int get_retry_after() const;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &sb, const HttpQuery &q);
|
|
|
|
|
|
|
|
} // namespace td
|