aboutsummaryrefslogtreecommitdiffhomepage
path: root/tdnet/td/net/HttpQuery.h
blob: 59e9958716e50f6c38f07498cea377e218464ba8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2026
//
// 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"
#include "td/utils/port/IPAddress.h"
#include "td/utils/Slice.h"
#include "td/utils/StringBuilder.h"

#include <utility>

namespace td {

class HttpQuery {
 public:
  enum class Type : int8 { Empty, Get, Post, Response };

  vector<BufferSlice> container_;
  Type type_ = Type::Empty;
  int32 code_ = 0;
  MutableSlice url_path_;
  vector<std::pair<MutableSlice, MutableSlice>> args_;
  MutableSlice reason_;

  bool keep_alive_ = true;
  vector<std::pair<MutableSlice, MutableSlice>> headers_;
  vector<HttpFile> files_;
  MutableSlice content_;

  IPAddress peer_address_;

  Slice get_header(Slice key) const;

  MutableSlice get_arg(Slice key) const;

  vector<std::pair<string, string>> get_args() const;

  int get_retry_after() const;
};

StringBuilder &operator<<(StringBuilder &sb, const HttpQuery &q);

}  // namespace td