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/HttpFile.h"
|
|
|
|
|
|
|
|
#include "td/utils/buffer.h"
|
|
|
|
#include "td/utils/common.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 };
|
|
|
|
|
|
|
|
std::vector<BufferSlice> container_;
|
2018-10-26 16:11:20 +02:00
|
|
|
Type type_ = Type::EMPTY;
|
2018-12-31 20:04:05 +01:00
|
|
|
MutableSlice url_path_;
|
|
|
|
std::vector<std::pair<MutableSlice, MutableSlice>> args_;
|
2018-10-26 16:11:20 +02:00
|
|
|
int code_ = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
MutableSlice reason_;
|
|
|
|
|
2018-10-26 16:11:20 +02:00
|
|
|
bool keep_alive_ = true;
|
2018-12-31 20:04:05 +01:00
|
|
|
std::vector<std::pair<MutableSlice, MutableSlice>> headers_;
|
|
|
|
std::vector<HttpFile> files_;
|
|
|
|
MutableSlice content_;
|
|
|
|
|
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
|
|
|
|
2018-04-19 14:23:54 +02:00
|
|
|
std::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
|