diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/http/server/conn.cpp | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/http/server/conn.cpp')
-rw-r--r-- | library/cpp/http/server/conn.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/library/cpp/http/server/conn.cpp b/library/cpp/http/server/conn.cpp new file mode 100644 index 00000000000..38a76c4c309 --- /dev/null +++ b/library/cpp/http/server/conn.cpp @@ -0,0 +1,69 @@ +#include "conn.h" + +#include <util/network/socket.h> +#include <util/stream/buffered.h> + +class THttpServerConn::TImpl { +public: + inline TImpl(const TSocket& s, size_t outputBufferSize) + : S_(s) + , SI_(S_) + , SO_(S_) + , BO_(&SO_, outputBufferSize) + , HI_(&SI_) + , HO_(&BO_, &HI_) + { + } + + inline ~TImpl() { + } + + inline THttpInput* Input() noexcept { + return &HI_; + } + + inline THttpOutput* Output() noexcept { + return &HO_; + } + + inline void Reset() { + if (S_ != INVALID_SOCKET) { + // send RST packet to client + S_.SetLinger(true, 0); + S_.Close(); + } + } + +private: + TSocket S_; + TSocketInput SI_; + TSocketOutput SO_; + TBufferedOutput BO_; + THttpInput HI_; + THttpOutput HO_; +}; + +THttpServerConn::THttpServerConn(const TSocket& s) + : THttpServerConn(s, s.MaximumTransferUnit()) +{ +} + +THttpServerConn::THttpServerConn(const TSocket& s, size_t outputBufferSize) + : Impl_(new TImpl(s, outputBufferSize)) +{ +} + +THttpServerConn::~THttpServerConn() { +} + +THttpInput* THttpServerConn::Input() noexcept { + return Impl_->Input(); +} + +THttpOutput* THttpServerConn::Output() noexcept { + return Impl_->Output(); +} + +void THttpServerConn::Reset() { + return Impl_->Reset(); +} |