diff options
author | feldsherov <feldsherov@yandex-team.ru> | 2022-02-10 16:49:29 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:29 +0300 |
commit | e73723ec73b27276cd45b9b46b752138a51d669c (patch) | |
tree | 055f8efa1a290665c7be6bb571131e050cd9517a /library/cpp/http | |
parent | 4d75b7f76712a8150bd526a7ef43d279d9892eb7 (diff) | |
download | ydb-e73723ec73b27276cd45b9b46b752138a51d669c.tar.gz |
Restoring authorship annotation for <feldsherov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/http')
-rw-r--r-- | library/cpp/http/io/stream.cpp | 6 | ||||
-rw-r--r-- | library/cpp/http/io/stream_ut.cpp | 84 | ||||
-rw-r--r-- | library/cpp/http/server/conn.cpp | 24 | ||||
-rw-r--r-- | library/cpp/http/server/conn.h | 4 | ||||
-rw-r--r-- | library/cpp/http/server/http.cpp | 16 | ||||
-rw-r--r-- | library/cpp/http/server/http.h | 4 | ||||
-rw-r--r-- | library/cpp/http/server/http_ut.cpp | 74 |
7 files changed, 106 insertions, 106 deletions
diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp index 6689be684f..71f4b9f927 100644 --- a/library/cpp/http/io/stream.cpp +++ b/library/cpp/http/io/stream.cpp @@ -436,10 +436,10 @@ TString THttpInput::BestCompressionScheme(TArrayRef<const TStringBuf> codings) c ); } -TString THttpInput::BestCompressionScheme() const { +TString THttpInput::BestCompressionScheme() const { return BestCompressionScheme(TCompressionCodecFactory::Instance().GetBestCodecs()); -} - +} + bool THttpInput::GetContentLength(ui64& value) const noexcept { return Impl_->GetContentLength(value); } diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index 1ea35df675..deabe5de45 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -441,52 +441,52 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT(!result.Contains("content-length")); } - Y_UNIT_TEST(CodecsPriority) { - TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); + Y_UNIT_TEST(CodecsPriority) { + TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); TVector<TStringBuf> codecs = {"br", "gzip"}; - - THttpInput i(&request); - TString result; - TStringOutput out(result); - THttpOutput httpOut(&out, &i); - - httpOut.EnableKeepAlive(true); + + THttpInput i(&request); + TString result; + TStringOutput out(result); + THttpOutput httpOut(&out, &i); + + httpOut.EnableKeepAlive(true); httpOut.EnableCompression(codecs); - httpOut << "HTTP/1.1 200 OK\r\n"; - char answer[] = "Mary had a little lamb."; - httpOut << "Content-Length: " << strlen(answer) << "\r\n" - "\r\n"; - httpOut << answer; - httpOut.Finish(); - - Cdbg << result; - result.to_lower(); - UNIT_ASSERT(result.Contains("content-encoding: br")); - } - - Y_UNIT_TEST(CodecsPriority2) { - TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); + httpOut << "HTTP/1.1 200 OK\r\n"; + char answer[] = "Mary had a little lamb."; + httpOut << "Content-Length: " << strlen(answer) << "\r\n" + "\r\n"; + httpOut << answer; + httpOut.Finish(); + + Cdbg << result; + result.to_lower(); + UNIT_ASSERT(result.Contains("content-encoding: br")); + } + + Y_UNIT_TEST(CodecsPriority2) { + TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); TVector<TStringBuf> codecs = {"gzip", "br"}; - - THttpInput i(&request); - TString result; - TStringOutput out(result); - THttpOutput httpOut(&out, &i); - - httpOut.EnableKeepAlive(true); + + THttpInput i(&request); + TString result; + TStringOutput out(result); + THttpOutput httpOut(&out, &i); + + httpOut.EnableKeepAlive(true); httpOut.EnableCompression(codecs); - httpOut << "HTTP/1.1 200 OK\r\n"; - char answer[] = "Mary had a little lamb."; - httpOut << "Content-Length: " << strlen(answer) << "\r\n" - "\r\n"; - httpOut << answer; - httpOut.Finish(); - - Cdbg << result; - result.to_lower(); - UNIT_ASSERT(result.Contains("content-encoding: gzip")); - } - + httpOut << "HTTP/1.1 200 OK\r\n"; + char answer[] = "Mary had a little lamb."; + httpOut << "Content-Length: " << strlen(answer) << "\r\n" + "\r\n"; + httpOut << answer; + httpOut.Finish(); + + Cdbg << result; + result.to_lower(); + UNIT_ASSERT(result.Contains("content-encoding: gzip")); + } + Y_UNIT_TEST(HasTrailers) { TMemoryInput response( "HTTP/1.1 200 OK\r\n" diff --git a/library/cpp/http/server/conn.cpp b/library/cpp/http/server/conn.cpp index 38a76c4c30..eee1e95a5f 100644 --- a/library/cpp/http/server/conn.cpp +++ b/library/cpp/http/server/conn.cpp @@ -26,14 +26,14 @@ public: return &HO_; } - inline void Reset() { - if (S_ != INVALID_SOCKET) { - // send RST packet to client - S_.SetLinger(true, 0); - S_.Close(); - } - } - + inline void Reset() { + if (S_ != INVALID_SOCKET) { + // send RST packet to client + S_.SetLinger(true, 0); + S_.Close(); + } + } + private: TSocket S_; TSocketInput SI_; @@ -63,7 +63,7 @@ THttpInput* THttpServerConn::Input() noexcept { THttpOutput* THttpServerConn::Output() noexcept { return Impl_->Output(); } - -void THttpServerConn::Reset() { - return Impl_->Reset(); -} + +void THttpServerConn::Reset() { + return Impl_->Reset(); +} diff --git a/library/cpp/http/server/conn.h b/library/cpp/http/server/conn.h index 3aa5329af4..181bc3fc5c 100644 --- a/library/cpp/http/server/conn.h +++ b/library/cpp/http/server/conn.h @@ -29,8 +29,8 @@ public: return Output()->CanBeKeepAlive(); } - void Reset(); - + void Reset(); + private: class TImpl; THolder<TImpl> Impl_; diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index 128583bdd7..00ca18e1cb 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -668,14 +668,14 @@ void TClientRequest::ReleaseConnection() { } } -void TClientRequest::ResetConnection() { - if (HttpConn_) { - // send RST packet to client - HttpConn_->Reset(); - HttpConn_.Destroy(); - } -} - +void TClientRequest::ResetConnection() { + if (HttpConn_) { + // send RST packet to client + HttpConn_->Reset(); + HttpConn_.Destroy(); + } +} + void TClientRequest::Process(void* ThreadSpecificResource) { THolder<TClientRequest> this_(this); diff --git a/library/cpp/http/server/http.h b/library/cpp/http/server/http.h index b292d38f27..1328bdce3f 100644 --- a/library/cpp/http/server/http.h +++ b/library/cpp/http/server/http.h @@ -128,8 +128,8 @@ public: void ReleaseConnection(); - void ResetConnection(); - + void ResetConnection(); + private: /* * Processes the request after 'connection' been created and 'Headers' been read diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp index cc62bb988e..16f72df972 100644 --- a/library/cpp/http/server/http_ut.cpp +++ b/library/cpp/http/server/http_ut.cpp @@ -481,29 +481,29 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { ExceptionMessage = CurrentExceptionMessage(); } - TString ExceptionMessage; - }; - - class TResetConnectionServer: public THttpServer::ICallBack { - class TRequest: public TClientRequest { - public: - bool Reply(void* /*tsr*/) override { - Output() << "HTTP/1.1"; - ResetConnection(); - - return true; - } - }; - + TString ExceptionMessage; + }; + + class TResetConnectionServer: public THttpServer::ICallBack { + class TRequest: public TClientRequest { + public: + bool Reply(void* /*tsr*/) override { + Output() << "HTTP/1.1"; + ResetConnection(); + + return true; + } + }; + public: - TClientRequest* CreateClient() override { - return new TRequest(); - } - - void OnException() override { - ExceptionMessage = CurrentExceptionMessage(); - } - + TClientRequest* CreateClient() override { + return new TRequest(); + } + + void OnException() override { + ExceptionMessage = CurrentExceptionMessage(); + } + TString ExceptionMessage; }; @@ -526,21 +526,21 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { } }; - Y_UNIT_TEST(TTestResetConnection) { - TPortManager pm; - const ui16 port = pm.GetPort(); - - TResetConnectionServer serverImpl; - THttpServer server(&serverImpl, THttpServer::TOptions(port)); - UNIT_ASSERT(server.Start()); - - TTestRequest r(port, "request"); - - UNIT_ASSERT_EXCEPTION_CONTAINS(r.Execute(), TSystemError, "Connection reset by peer"); - - server.Stop(); - }; - + Y_UNIT_TEST(TTestResetConnection) { + TPortManager pm; + const ui16 port = pm.GetPort(); + + TResetConnectionServer serverImpl; + THttpServer server(&serverImpl, THttpServer::TOptions(port)); + UNIT_ASSERT(server.Start()); + + TTestRequest r(port, "request"); + + UNIT_ASSERT_EXCEPTION_CONTAINS(r.Execute(), TSystemError, "Connection reset by peer"); + + server.Stop(); + }; + Y_UNIT_TEST(TTestReleaseConnection) { TPortManager pm; const ui16 port = pm.GetPort(); |