diff options
author | Alexey Efimov <xeno@prnwatch.com> | 2022-05-17 11:34:57 +0300 |
---|---|---|
committer | Alexey Efimov <xeno@prnwatch.com> | 2022-05-17 11:34:57 +0300 |
commit | 742718e4953ed9e9f897f5194871fc7cec65caa3 (patch) | |
tree | 6501c24969779138b433d19606a22791742e38b9 /library/cpp | |
parent | 1e1dfc1b3545147948cc2190bb15161f630507e9 (diff) | |
download | ydb-742718e4953ed9e9f897f5194871fc7cec65caa3.tar.gz |
add http-mon via ic proxy KIKIMR-14742
ref:b3a758f33f4578f7f8ce2e822783faf41a5ab6cd
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/actors/http/http.h | 11 | ||||
-rw-r--r-- | library/cpp/actors/http/http_ut.cpp | 3 | ||||
-rw-r--r-- | library/cpp/monlib/service/pages/index_mon_page.cpp | 33 | ||||
-rw-r--r-- | library/cpp/monlib/service/pages/index_mon_page.h | 5 | ||||
-rw-r--r-- | library/cpp/monlib/service/pages/mon_page.h | 4 |
5 files changed, 54 insertions, 2 deletions
diff --git a/library/cpp/actors/http/http.h b/library/cpp/actors/http/http.h index 54ed5d6d8fb..38e616cafa2 100644 --- a/library/cpp/actors/http/http.h +++ b/library/cpp/actors/http/http.h @@ -116,6 +116,11 @@ public: } return true; } + + // non-destructive variant of AsString + TString AsString() const { + return TString(Data(), Size()); + } }; class THttpRequest { @@ -674,6 +679,12 @@ public: , Address(address) {} + THttpIncomingRequest(TStringBuf content, std::shared_ptr<THttpEndpointInfo> endpoint, const THttpConfig::SocketAddressType& address) + : THttpParser(content) + , Endpoint(std::move(endpoint)) + , Address(address) + {} + bool IsConnectionClose() const { if (Connection.empty()) { return Version == "1.0"; diff --git a/library/cpp/actors/http/http_ut.cpp b/library/cpp/actors/http/http_ut.cpp index 4ec7761da91..e87de6b6e15 100644 --- a/library/cpp/actors/http/http_ut.cpp +++ b/library/cpp/actors/http/http_ut.cpp @@ -182,8 +182,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { cookies.Set("cookie2", "45678"); headers.Set("Cookie", cookies.Render()); request->Set(headers); - TString requestData; - request->AsString(requestData); + TString requestData = request->AsString(); UNIT_ASSERT_VALUES_EQUAL(requestData, "GET /data/url HTTP/1.1\r\nHost: www.yandex.ru\r\nAccept: */*\r\nCookie: cookie1=123456; cookie2=45678;\r\n"); } diff --git a/library/cpp/monlib/service/pages/index_mon_page.cpp b/library/cpp/monlib/service/pages/index_mon_page.cpp index 1d3d6dac375..de2a5a058cd 100644 --- a/library/cpp/monlib/service/pages/index_mon_page.cpp +++ b/library/cpp/monlib/service/pages/index_mon_page.cpp @@ -106,6 +106,39 @@ IMonPage* TIndexMonPage::FindPage(const TString& relativePath) { } } +IMonPage* TIndexMonPage::FindPageByAbsolutePath(const TString& absolutePath) { + TIndexMonPage* page = this; + TString path = absolutePath; + if (path.StartsWith("/")) { + path.erase(0, 1); + } + while (!path.empty()) { + TString tryPath = path; + while (!tryPath.empty()) { + IMonPage* found = page->FindPage(tryPath); + if (found == nullptr) { + size_t slash = tryPath.find_last_of('/'); + if (slash == TString::npos) { + return nullptr; + } + tryPath.resize(slash); + } else { + if (tryPath.size() == path.size()) { + return found; + } + if (found->IsIndex()) { + path = path.substr(tryPath.size() + 1); + page = static_cast<TIndexMonPage*>(found); + break; + } else { + return found; + } + } + } + } + return nullptr; +} + TIndexMonPage* TIndexMonPage::FindIndexPage(const TString& relativePath) { return VerifyDynamicCast<TIndexMonPage*>(FindPage(relativePath)); } diff --git a/library/cpp/monlib/service/pages/index_mon_page.h b/library/cpp/monlib/service/pages/index_mon_page.h index bf514a31056..af96bcd2b9c 100644 --- a/library/cpp/monlib/service/pages/index_mon_page.h +++ b/library/cpp/monlib/service/pages/index_mon_page.h @@ -18,6 +18,10 @@ namespace NMonitoring { ~TIndexMonPage() override { } + bool IsIndex() const override { + return true; + } + void Output(IMonHttpRequest& request) override; void OutputIndexPage(IMonHttpRequest& request); virtual void OutputIndex(IOutputStream& out, bool pathEndsWithSlash); @@ -30,6 +34,7 @@ namespace NMonitoring { IMonPage* FindPage(const TString& relativePath); TIndexMonPage* FindIndexPage(const TString& relativePath); + IMonPage* FindPageByAbsolutePath(const TString& absolutePath); void SortPages(); void ClearPages(); diff --git a/library/cpp/monlib/service/pages/mon_page.h b/library/cpp/monlib/service/pages/mon_page.h index 136647e5be2..215b58f0ae0 100644 --- a/library/cpp/monlib/service/pages/mon_page.h +++ b/library/cpp/monlib/service/pages/mon_page.h @@ -61,6 +61,10 @@ namespace NMonitoring { return !Title.empty(); } + virtual bool IsIndex() const { + return false; + } + virtual void Output(IMonHttpRequest& request) = 0; }; |