aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http/simple/http_client_options.h
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2022-11-24 13:14:34 +0300
committerDaniil Cherednik <dan.cherednik@gmail.com>2022-11-24 14:46:00 +0300
commit87f7fceed34bcafb8aaff351dd493a35c916986f (patch)
tree26809ec8f550aba8eb019e59adc3d48e51913eb2 /library/cpp/http/simple/http_client_options.h
parent11bc4015b8010ae201bf3eb33db7dba425aca35e (diff)
downloadydb-87f7fceed34bcafb8aaff351dd493a35c916986f.tar.gz
Ydb stable 22-4-4322.4.43
x-stable-origin-commit: 8d49d46cc834835bf3e50870516acd7376a63bcf
Diffstat (limited to 'library/cpp/http/simple/http_client_options.h')
-rw-r--r--library/cpp/http/simple/http_client_options.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/library/cpp/http/simple/http_client_options.h b/library/cpp/http/simple/http_client_options.h
new file mode 100644
index 0000000000..f2e964a462
--- /dev/null
+++ b/library/cpp/http/simple/http_client_options.h
@@ -0,0 +1,59 @@
+#pragma once
+
+#include <util/datetime/base.h>
+#include <library/cpp/string_utils/url/url.h>
+
+class TSimpleHttpClientOptions {
+ using TSelf = TSimpleHttpClientOptions;
+
+public:
+ TSimpleHttpClientOptions() = default;
+
+ explicit TSimpleHttpClientOptions(TStringBuf url) {
+ TStringBuf scheme, host;
+ GetSchemeHostAndPort(url, scheme, host, Port_);
+ Host_ = url.Head(scheme.size() + host.size());
+ }
+
+ TSelf& Host(TStringBuf host) {
+ Host_ = host;
+ return *this;
+ }
+
+ const TString& Host() const noexcept {
+ return Host_;
+ }
+
+ TSelf& Port(ui16 port) {
+ Port_ = port;
+ return *this;
+ }
+
+ ui16 Port() const noexcept {
+ return Port_;
+ }
+
+ TSelf& SocketTimeout(TDuration timeout) {
+ SocketTimeout_ = timeout;
+ return *this;
+ }
+
+ TDuration SocketTimeout() const noexcept {
+ return SocketTimeout_;
+ }
+
+ TSelf& ConnectTimeout(TDuration timeout) {
+ ConnectTimeout_ = timeout;
+ return *this;
+ }
+
+ TDuration ConnectTimeout() const noexcept {
+ return ConnectTimeout_;
+ }
+
+private:
+ TString Host_;
+ ui16 Port_;
+ TDuration SocketTimeout_ = TDuration::Seconds(5);
+ TDuration ConnectTimeout_ = TDuration::Seconds(30);
+};