diff options
author | platypus179 <platypus179@yandex-team.ru> | 2022-02-10 16:49:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:46 +0300 |
commit | cac99863f10ca292a64df9f7edb958ad22a02f86 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/http/io/stream_ut.cpp | |
parent | 2cd8af5a38e7de1bbb2a78b578853f5229cbf0c4 (diff) | |
download | ydb-cac99863f10ca292a64df9f7edb958ad22a02f86.tar.gz |
Restoring authorship annotation for <platypus179@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/http/io/stream_ut.cpp')
-rw-r--r-- | library/cpp/http/io/stream_ut.cpp | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index 7e20ba455b..1ea35df675 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -50,8 +50,8 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } Output().Finish(); - Parent_->LastRequestSentSize_ = Output().SentSize(); - + Parent_->LastRequestSentSize_ = Output().SentSize(); + return true; } @@ -69,13 +69,13 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { return new TRequest(this); } - size_t LastRequestSentSize() const { - return LastRequestSentSize_; - } - + size_t LastRequestSentSize() const { + return LastRequestSentSize_; + } + private: TString Res_; - size_t LastRequestSentSize_ = 0; + size_t LastRequestSentSize_ = 0; }; Y_UNIT_TEST(TestCodings1) { @@ -664,7 +664,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { TString result = outBuf.Str(); UNIT_ASSERT(!result.Contains(TStringBuf("0\r\n"))); } - + Y_UNIT_TEST(TestHttpOutputDisableCompressionHeader) { TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip\r\n\r\n"); const TString data = "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"; @@ -686,47 +686,47 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT(result.Contains(data)); } - size_t DoTestHttpOutputSize(const TString& res, bool enableCompession) { - TTestHttpServer serverImpl(res); - TPortManager pm; - - const ui16 port = pm.GetPort(); - THttpServer server(&serverImpl, - THttpServer::TOptions(port) - .EnableKeepAlive(true) - .EnableCompression(enableCompession)); - UNIT_ASSERT(server.Start()); - - TNetworkAddress addr("localhost", port); - TSocket s(addr); - - { - TSocketOutput so(s); - THttpOutput out(&so); - out << "GET / HTTP/1.1\r\n" - "Host: www.yandex.ru\r\n" - "Connection: Keep-Alive\r\n" - "Accept-Encoding: gzip\r\n" - "\r\n"; - out.Finish(); - } - - TSocketInput si(s); - THttpInput input(&si); - - unsigned httpCode = ParseHttpRetCode(input.FirstLine()); - UNIT_ASSERT_VALUES_EQUAL(httpCode, 200u); - - UNIT_ASSERT_VALUES_EQUAL(res, input.ReadAll()); - - server.Stop(); - - return serverImpl.LastRequestSentSize(); - } - - Y_UNIT_TEST(TestHttpOutputSize) { - TString res = "qqqqqq"; - UNIT_ASSERT_VALUES_EQUAL(res.size(), DoTestHttpOutputSize(res, false)); - UNIT_ASSERT_VALUES_UNEQUAL(res.size(), DoTestHttpOutputSize(res, true)); - } + size_t DoTestHttpOutputSize(const TString& res, bool enableCompession) { + TTestHttpServer serverImpl(res); + TPortManager pm; + + const ui16 port = pm.GetPort(); + THttpServer server(&serverImpl, + THttpServer::TOptions(port) + .EnableKeepAlive(true) + .EnableCompression(enableCompession)); + UNIT_ASSERT(server.Start()); + + TNetworkAddress addr("localhost", port); + TSocket s(addr); + + { + TSocketOutput so(s); + THttpOutput out(&so); + out << "GET / HTTP/1.1\r\n" + "Host: www.yandex.ru\r\n" + "Connection: Keep-Alive\r\n" + "Accept-Encoding: gzip\r\n" + "\r\n"; + out.Finish(); + } + + TSocketInput si(s); + THttpInput input(&si); + + unsigned httpCode = ParseHttpRetCode(input.FirstLine()); + UNIT_ASSERT_VALUES_EQUAL(httpCode, 200u); + + UNIT_ASSERT_VALUES_EQUAL(res, input.ReadAll()); + + server.Stop(); + + return serverImpl.LastRequestSentSize(); + } + + Y_UNIT_TEST(TestHttpOutputSize) { + TString res = "qqqqqq"; + UNIT_ASSERT_VALUES_EQUAL(res.size(), DoTestHttpOutputSize(res, false)); + UNIT_ASSERT_VALUES_UNEQUAL(res.size(), DoTestHttpOutputSize(res, true)); + } } // THttpStreamTest suite |