diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/http/server/http.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/http/server/http.h')
-rw-r--r-- | library/cpp/http/server/http.h | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/library/cpp/http/server/http.h b/library/cpp/http/server/http.h index b292d38f27..1b72215706 100644 --- a/library/cpp/http/server/http.h +++ b/library/cpp/http/server/http.h @@ -1,92 +1,92 @@ #pragma once -#include "conn.h" -#include "options.h" - +#include "conn.h" +#include "options.h" + #include <util/thread/pool.h> #include <library/cpp/http/io/stream.h> -#include <util/memory/blob.h> +#include <util/memory/blob.h> #include <util/generic/ptr.h> #include <util/generic/vector.h> #include <util/system/atomic.h> - + class IThreadFactory; -class TClientRequest; -class TClientConnection; +class TClientRequest; +class TClientConnection; -class THttpServer { +class THttpServer { friend class TClientRequest; friend class TClientConnection; - + public: class ICallBack { - public: + public: struct TFailLogData { int failstate; TString url; }; - + virtual ~ICallBack() { } - + virtual void OnFailRequest(int /*failstate*/) { } - + virtual void OnFailRequestEx(const TFailLogData& d) { OnFailRequest(d.failstate); } - + virtual void OnException() { } - + virtual void OnMaxConn() { } - + virtual TClientRequest* CreateClient() = 0; - + virtual void OnListenStart() { } - + virtual void OnListenStop() { } - + virtual void OnWait() { } - - virtual void* CreateThreadSpecificResource() { + + virtual void* CreateThreadSpecificResource() { return nullptr; } - + virtual void DestroyThreadSpecificResource(void*) { } }; - + typedef THttpServerOptions TOptions; typedef TSimpleSharedPtr<IThreadPool> TMtpQueueRef; - + THttpServer(ICallBack* cb, const TOptions& options = TOptions(), IThreadFactory* pool = nullptr); THttpServer(ICallBack* cb, TMtpQueueRef mainWorkers, TMtpQueueRef failWorkers, const TOptions& options = TOptions()); virtual ~THttpServer(); - + bool Start(); - + // shutdown a.s.a.p. void Stop(); - + // graceful shutdown with serving all already open connections void Shutdown(); - + void Wait(); int GetErrorCode(); const char* GetError(); void RestartRequestThreads(ui32 nTh, ui32 maxQS); const TOptions& Options() const noexcept; i64 GetClientCount() const; - + class TImpl; size_t GetRequestQueueSize() const; size_t GetFailQueueSize() const; - + const IThreadPool& GetRequestQueue() const; const IThreadPool& GetFailQueue() const; @@ -102,32 +102,32 @@ private: /** * @deprecated Use TRequestReplier instead */ -class TClientRequest: public IObjectInQueue { +class TClientRequest: public IObjectInQueue { friend class THttpServer::TImpl; - + public: TClientRequest(); ~TClientRequest() override; - + inline THttpInput& Input() noexcept { return *HttpConn_->Input(); } - + inline THttpOutput& Output() noexcept { return *HttpConn_->Output(); } - + THttpServer* HttpServ() const noexcept; const TSocket& Socket() const noexcept; NAddr::IRemoteAddrRef GetListenerSockAddrRef() const noexcept; TInstant AcceptMoment() const noexcept; - + bool IsLocal() const; bool CheckLoopback(); void ProcessFailRequest(int failstate); - + void ReleaseConnection(); - + void ResetConnection(); private: @@ -138,17 +138,17 @@ private: */ virtual bool Reply(void* ThreadSpecificResource); void Process(void* ThreadSpecificResource) override; - + public: TVector<std::pair<TString, TString>> ParsedHeaders; TString RequestString; - + private: THolder<TClientConnection> Conn_; THolder<THttpServerConn> HttpConn_; -}; - -class TRequestReplier: public TClientRequest { +}; + +class TRequestReplier: public TClientRequest { public: TRequestReplier(); ~TRequestReplier() override; |