diff options
author | alexv-smirnov <alex@ydb.tech> | 2022-08-18 16:52:30 +0300 |
---|---|---|
committer | alexv-smirnov <alex@ydb.tech> | 2022-08-18 16:52:30 +0300 |
commit | c140abc954b61ab7d86af80bdeced01482d9971a (patch) | |
tree | c47d70fa3213240d5e0eb59787a5325782a360de /library/cpp/http/simple/http_client_options.h | |
parent | 0ce07b9705ed20e3fce2759eae41496014ca4c33 (diff) | |
download | ydb-c140abc954b61ab7d86af80bdeced01482d9971a.tar.gz |
temp fix ydb oss sync config to unlock sync on /vendor dependency
Diffstat (limited to 'library/cpp/http/simple/http_client_options.h')
-rw-r--r-- | library/cpp/http/simple/http_client_options.h | 59 |
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); +}; |