diff options
author | annashest18 <annashest18@yandex-team.com> | 2023-10-22 13:19:53 +0300 |
---|---|---|
committer | annashest18 <annashest18@yandex-team.com> | 2023-10-22 13:40:13 +0300 |
commit | 24a44df2ab01109cefd64d4bfad05c66e7ebd2af (patch) | |
tree | 1ec1ca95a2a8aceaa383fde2e19e61db9ab4fe02 /yt/cpp/mapreduce/http/http.cpp | |
parent | a991b019f74cbfe6efb40c3b68b46a1ac2a9bd09 (diff) | |
download | ydb-24a44df2ab01109cefd64d4bfad05c66e7ebd2af.tar.gz |
add using http-proxy for reading table from YT
add using http-proxy for reading table from YT
Нам нужна возможность ходить в YT через HTTP proxy для чтения таблиц, используя С++ клиент не из контура Яндекса, к сожалению, сейчас такой возможности нет. В этом ПР черновик изменения, которого нам достаточно
https://a.yandex-team.ru/review/4676436/details - тут это же изменение в YT + коммит с тем, как мы планируем использовать
Diffstat (limited to 'yt/cpp/mapreduce/http/http.cpp')
-rw-r--r-- | yt/cpp/mapreduce/http/http.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/yt/cpp/mapreduce/http/http.cpp b/yt/cpp/mapreduce/http/http.cpp index c5c358c46c0..987b6daf4ae 100644 --- a/yt/cpp/mapreduce/http/http.cpp +++ b/yt/cpp/mapreduce/http/http.cpp @@ -210,6 +210,16 @@ void THttpHeader::SetToken(const TString& token) Token = token; } +void THttpHeader::SetProxyAddress(const TString& proxyAddress) +{ + ProxyAddress = proxyAddress; +} + +void THttpHeader::SetHostPort(const TString& hostPort) +{ + HostPort = hostPort; +} + void THttpHeader::SetImpersonationUser(const TString& impersonationUser) { ImpersonationUser = impersonationUser; @@ -250,10 +260,19 @@ TString THttpHeader::GetCommand() const return Command; } -TString THttpHeader::GetUrl() const +TString THttpHeader::GetUrl(bool needProxy) const { TStringStream url; + if (needProxy && !ProxyAddress.empty()) { + url << ProxyAddress << "/"; + return url.Str(); + } + + if (!ProxyAddress.empty()) { + url << HostPort; + } + if (IsApi) { url << "/api/" << TConfig::Get()->ApiVersion << "/" << Command; } else { @@ -274,7 +293,7 @@ TString THttpHeader::GetHeaderAsString(const TString& hostName, const TString& r result << Method << " " << GetUrl() << " HTTP/1.1\r\n"; - GetHeader(hostName, requestId, includeParameters).Get()->WriteTo(&result); + GetHeader(HostPort.Empty() ? hostName : HostPort, requestId, includeParameters).Get()->WriteTo(&result); if (ShouldAcceptFraming()) { result << "X-YT-Accept-Framing: 1\r\n"; @@ -914,7 +933,7 @@ void THttpRequest::Connect(TString hostName, TDuration socketTimeout) IOutputStream* THttpRequest::StartRequestImpl(const THttpHeader& header, bool includeParameters) { auto strHeader = header.GetHeaderAsString(HostName, RequestId, includeParameters); - Url_ = header.GetUrl(); + Url_ = header.GetUrl(true); LogRequest(header, Url_, includeParameters, RequestId, HostName); |