diff options
author | Arslan Urtashev <urtashev@gmail.com> | 2022-02-10 16:48:55 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:55 +0300 |
commit | b97740540e7302cec9efa181e106ae1990a0cc1c (patch) | |
tree | 1a2a0bfe523c3272d207e2d75254a41d3945a3bb /library/cpp/http | |
parent | 31789673dc3562bc7540e00fe031ba84ae282c24 (diff) | |
download | ydb-b97740540e7302cec9efa181e106ae1990a0cc1c.tar.gz |
Restoring authorship annotation for Arslan Urtashev <urtashev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/http')
-rw-r--r-- | library/cpp/http/misc/httpreqdata.cpp | 20 | ||||
-rw-r--r-- | library/cpp/http/misc/httpreqdata.h | 2 | ||||
-rw-r--r-- | library/cpp/http/misc/httpreqdata_ut.cpp | 30 |
3 files changed, 26 insertions, 26 deletions
diff --git a/library/cpp/http/misc/httpreqdata.cpp b/library/cpp/http/misc/httpreqdata.cpp index f6951f68cd..035eccf7b9 100644 --- a/library/cpp/http/misc/httpreqdata.cpp +++ b/library/cpp/http/misc/httpreqdata.cpp @@ -1,7 +1,7 @@ #include "httpreqdata.h" -#include <util/stream/mem.h> - +#include <util/stream/mem.h> + TBaseServerRequestData::TBaseServerRequestData(SOCKET s) : Addr(nullptr) , Host() @@ -46,14 +46,14 @@ void TBaseServerRequestData::AppendQueryString(const char* str, size_t length) { SearchLength = ModifiedQueryString.size() - 1; // ignore terminator } -void TBaseServerRequestData::SetRemoteAddr(TStringBuf addr) { - TMemoryOutput out(AddrData, Y_ARRAY_SIZE(AddrData) - 1); - out.Write(addr.substr(0, Y_ARRAY_SIZE(AddrData) - 1)); - *out.Buf() = '\0'; - - Addr = AddrData; -} - +void TBaseServerRequestData::SetRemoteAddr(TStringBuf addr) { + TMemoryOutput out(AddrData, Y_ARRAY_SIZE(AddrData) - 1); + out.Write(addr.substr(0, Y_ARRAY_SIZE(AddrData) - 1)); + *out.Buf() = '\0'; + + Addr = AddrData; +} + const char* TBaseServerRequestData::RemoteAddr() const { if (!Addr) { *AddrData = 0; diff --git a/library/cpp/http/misc/httpreqdata.h b/library/cpp/http/misc/httpreqdata.h index 16e59c4d78..6bc816fcf5 100644 --- a/library/cpp/http/misc/httpreqdata.h +++ b/library/cpp/http/misc/httpreqdata.h @@ -57,7 +57,7 @@ public: void AppendQueryString(const char* str, size_t length); const char* RemoteAddr() const; - void SetRemoteAddr(TStringBuf addr); + void SetRemoteAddr(TStringBuf addr); const char* HeaderIn(TStringBuf key) const; const THttpHeadersContainer& HeadersIn() const { diff --git a/library/cpp/http/misc/httpreqdata_ut.cpp b/library/cpp/http/misc/httpreqdata_ut.cpp index e7f16ef27c..554a4c9645 100644 --- a/library/cpp/http/misc/httpreqdata_ut.cpp +++ b/library/cpp/http/misc/httpreqdata_ut.cpp @@ -135,20 +135,20 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { } Y_UNIT_TEST(SetRemoteAddrSimple) { - static const TString TEST = "abacaba.search.yandex.net"; - - TServerRequestData rd; - rd.SetRemoteAddr(TEST); - UNIT_ASSERT_STRINGS_EQUAL(TEST, rd.RemoteAddr()); - } - + static const TString TEST = "abacaba.search.yandex.net"; + + TServerRequestData rd; + rd.SetRemoteAddr(TEST); + UNIT_ASSERT_STRINGS_EQUAL(TEST, rd.RemoteAddr()); + } + Y_UNIT_TEST(SetRemoteAddrRandom) { - for (size_t size = 0; size < 2 * INET6_ADDRSTRLEN; ++size) { - const TString test = NUnitTest::RandomString(size, size); - TServerRequestData rd; - rd.SetRemoteAddr(test); - UNIT_ASSERT_STRINGS_EQUAL(test.substr(0, INET6_ADDRSTRLEN - 1), rd.RemoteAddr()); - } - } - + for (size_t size = 0; size < 2 * INET6_ADDRSTRLEN; ++size) { + const TString test = NUnitTest::RandomString(size, size); + TServerRequestData rd; + rd.SetRemoteAddr(test); + UNIT_ASSERT_STRINGS_EQUAL(test.substr(0, INET6_ADDRSTRLEN - 1), rd.RemoteAddr()); + } + } + } // TRequestServerDataTest |