10#include <userver/clients/dns/resolver_fwd.hpp>
11#include <userver/clients/http/error.hpp>
12#include <userver/clients/http/plugin.hpp>
13#include <userver/clients/http/response.hpp>
14#include <userver/clients/http/response_future.hpp>
15#include <userver/concurrent/queue.hpp>
16#include <userver/crypto/certificate.hpp>
17#include <userver/crypto/private_key.hpp>
18#include <userver/http/http_version.hpp>
19#include <userver/utils/impl/source_location.hpp>
21USERVER_NAMESPACE_BEGIN
28namespace clients::http {
31class StreamedResponse;
36class DestinationStatistics;
37struct TestsuiteConfig;
44enum class HttpMethod { kGet, kPost, kHead, kPut, kDelete, kPatch, kOptions };
46std::string_view ToStringView(HttpMethod method);
48using USERVER_NAMESPACE::
http::HttpVersion;
73ProxyAuthType ProxyAuthTypeFromString(
const std::string& auth_name);
79 using Cookies = std::unordered_map<std::string, std::string, utils::StrCaseHash>;
85 RequestStats&& req_stats,
86 const std::shared_ptr<DestinationStatistics>& dest_stats,
88 impl::PluginPipeline& plugin_pipeline,
100 Request&
get(
const std::string& url) &;
101 Request get(
const std::string& url) &&;
106 Request&
head(
const std::string& url) &;
107 Request head(
const std::string& url) &&;
112 Request&
post(
const std::string& url, std::string data = {}) &;
113 Request post(
const std::string& url, std::string data = {}) &&;
115 Request&
post(
const std::string& url, Form&& form) &;
116 Request post(
const std::string& url, Form&& form) &&;
121 Request&
put(
const std::string& url, std::string data = {}) &;
122 Request put(
const std::string& url, std::string data = {}) &&;
128 Request&
patch(
const std::string& url, std::string data = {}) &;
129 Request patch(
const std::string& url, std::string data = {}) &&;
133 Request delete_method() &&;
136 Request delete_method(
const std::string& url) &&;
139 Request delete_method(
const std::string& url, std::string data) &&;
143 Request set_custom_http_request_method(std::string method) &&;
146 Request&
url(
const std::string& url) &;
147 Request url(
const std::string& url) &&;
149 Request&
data(std::string data) &;
150 Request data(std::string data) &&;
153 Request form(Form&& form) &&;
156 Request headers(
const Headers& headers) &&;
158 Request&
headers(
const std::initializer_list<std::pair<std::string_view, std::string_view>>& headers) &;
159 Request headers(
const std::initializer_list<std::pair<std::string_view, std::string_view>>& headers) &&;
162 Request http_auth_type(
HttpAuthType value,
bool auth_only, std::string_view user, std::string_view password) &&;
165 Request proxy_headers(
const Headers& headers) &&;
167 Request&
proxy_headers(
const std::initializer_list<std::pair<std::string_view, std::string_view>>& headers) &;
168 Request proxy_headers(
const std::initializer_list<std::pair<std::string_view, std::string_view>>& headers) &&;
171 Request user_agent(
const std::string& value) &&;
173 Request&
proxy(
const std::string& value) &;
174 Request proxy(
const std::string& value) &&;
180 Request cookies(
const Cookies& cookies) &&;
182 Request&
cookies(
const std::unordered_map<std::string, std::string>& cookies) &;
183 Request cookies(
const std::unordered_map<std::string, std::string>& cookies) &&;
186 Request follow_redirects(
bool follow =
true) &&;
189 Request timeout(
long timeout_ms) &&;
190 Request& timeout(std::chrono::milliseconds timeout_ms) & {
return timeout(timeout_ms.count()); }
191 Request timeout(std::chrono::milliseconds timeout_ms) && {
return std::move(
this->timeout(timeout_ms.count())); }
194 Request verify(
bool verify =
true) &&;
196 Request&
ca_info(
const std::string& file_path) &;
197 Request ca_info(
const std::string& file_path) &&;
203 Request crl_file(
const std::string& file_path) &&;
220 Request&
retry(
short retries = 3,
bool on_fails =
true) &;
221 Request retry(
short retries = 3,
bool on_fails =
true) &&;
227 Request unix_socket_path(
const std::string& path) &&;
231 Request use_ipv4() &&;
234 Request use_ipv6() &&;
239 Request connect_to(
const ConnectTo& connect_to) &&;
241 template <
typename T>
242 std::enable_if_t<std::is_same_v<ConnectTo, T>, Request&> connect_to(T&&) {
243 static_assert(!
sizeof(T),
"ConnectTo argument must not be temporary, it must outlive Request");
251 Request SetLoggedUrl(std::string url) &&;
257 Request SetDestinationMetricName(
const std::string& destination) &&;
261 void SetTestsuiteConfig(
const std::shared_ptr<
const TestsuiteConfig>& config) &;
263 void SetAllowedUrlsExtra(
const std::vector<std::string>& urls) &;
272 Request DisableReplyDecoding() &&;
274 void SetCancellationPolicy(CancellationPolicy cp);
299 const std::shared_ptr<
concurrent::StringStreamQueue>& queue,
310 [[nodiscard]] std::shared_ptr<Response>
perform(
316 const std::string& GetUrl() && =
delete;
320 const std::string& GetData() && =
delete;
326 std::shared_ptr<RequestState> pimpl_;