diff options
| author | kulikov <[email protected]> | 2026-06-28 20:01:43 +0300 |
|---|---|---|
| committer | kulikov <[email protected]> | 2026-06-28 20:40:40 +0300 |
| commit | ab71516ca6760fe71bedeb59108e98b75da1c41b (patch) | |
| tree | e02c780d81c2d31d4519f888f1b0b1bd6a394fc9 /library/cpp/http/server/http.cpp | |
| parent | 781a6d3b907bb61336bb73e783a557ee820421a2 (diff) | |
Allow custom socket streams in library/cpp/http/server
Prepare to use external coroutine/fiber/etc pool with non-blocking read/writes instead of plain blocking system threads. We already can replace system thread pool with something else, allow to inject different streams around connection socket:
- move common part of http connection (http streams and output buffer) directly into it;
- replace connection Impl with socket streams provider;
- add TClientRequest::CreateHttpConnection factory;
- check that we are able to override socket streams in unittest.
commit_hash:afe39ce57ee1d10673f4c36a12e01b467d9f77b0
Diffstat (limited to 'library/cpp/http/server/http.cpp')
| -rw-r--r-- | library/cpp/http/server/http.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index 13088f5e442..79a1194c770 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -725,6 +725,10 @@ void TClientRequest::ResetConnection() { } } +THolder<THttpServerConn> TClientRequest::CreateHttpConnection(const TSocket& s, size_t outputBufferSize) { + return MakeHolder<THttpServerConn>(s, outputBufferSize); +} + void TClientRequest::Process(void* ThreadSpecificResource) { THolder<TClientRequest> this_(this); @@ -733,11 +737,7 @@ void TClientRequest::Process(void* ThreadSpecificResource) { try { if (!HttpConn_) { const size_t outputBufferSize = HttpServ()->Options().OutputBufferSize; - if (outputBufferSize) { - HttpConn_.Reset(new THttpServerConn(Socket(), outputBufferSize)); - } else { - HttpConn_.Reset(new THttpServerConn(Socket())); - } + HttpConn_ = CreateHttpConnection(Socket(), outputBufferSize ? outputBufferSize : Socket().MaximumTransferUnit()); auto maxRequestsPerConnection = HttpServ()->Options().MaxRequestsPerConnection; HttpConn_->Output()->EnableKeepAlive(HttpServ()->Options().KeepAliveEnabled && (!maxRequestsPerConnection || Conn_->ReceivedRequests < maxRequestsPerConnection)); |
