diff options
author | komels <komels@yandex-team.ru> | 2022-04-14 13:10:53 +0300 |
---|---|---|
committer | komels <komels@yandex-team.ru> | 2022-04-14 13:10:53 +0300 |
commit | 21c9b0e6b039e9765eb414c406c2b86e8cea6850 (patch) | |
tree | f40ebc18ff8958dfbd189954ad024043ca983ea5 /library/cpp/http/simple/http_client_options.h | |
parent | 9a4effa852abe489707139c2b260dccc6f4f9aa9 (diff) | |
download | ydb-21c9b0e6b039e9765eb414c406c2b86e8cea6850.tar.gz |
Final part on compatibility layer: LOGBROKER-7215
ref:777c67aadbf705d19034a09a792b2df61ba53697
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); +}; |