diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-11-20 17:37:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 17:37:57 +0000 |
commit | f76323e9b295c15751e51e3443aa47a36bee8023 (patch) | |
tree | 4113c8cad473a33e0f746966e0cf087252fa1d7a /yt/cpp/mapreduce/http/http.h | |
parent | 753ecb8d410a4cb459c26f3a0082fb2d1724fe63 (diff) | |
parent | a7b9a6afea2a9d7a7bfac4c5eb4c1a8e60adb9e6 (diff) | |
download | ydb-f76323e9b295c15751e51e3443aa47a36bee8023.tar.gz |
Merge pull request #11788 from ydb-platform/mergelibs-241120-1113
Library import 241120-1113
Diffstat (limited to 'yt/cpp/mapreduce/http/http.h')
-rw-r--r-- | yt/cpp/mapreduce/http/http.h | 87 |
1 files changed, 48 insertions, 39 deletions
diff --git a/yt/cpp/mapreduce/http/http.h b/yt/cpp/mapreduce/http/http.h index 95595959ad..618b1e2c22 100644 --- a/yt/cpp/mapreduce/http/http.h +++ b/yt/cpp/mapreduce/http/http.h @@ -39,6 +39,12 @@ enum class EFrameType KeepAlive = 0x02, }; +struct TRequestContext +{ + TString RequestId; + TString HostName; + TString Method; +}; class THttpHeader { @@ -82,24 +88,23 @@ private: bool ShouldAcceptFraming() const; private: - const TString Method; - const TString Command; - const bool IsApi; - - TNode::TMapType Parameters; - TString ImpersonationUser; - TString Token; - TString ServiceTicket; - TNode Attributes; - TString ProxyAddress; - TString HostPort; - -private: - TMaybe<TFormat> InputFormat = TFormat::YsonText(); - TMaybe<TFormat> OutputFormat = TFormat::YsonText(); - - TString RequestCompression = "identity"; - TString ResponseCompression = "identity"; + const TString Method_; + const TString Command_; + const bool IsApi_; + + TNode::TMapType Parameters_; + TString ImpersonationUser_; + TString Token_; + TString ServiceTicket_; + TNode Attributes_; + TString ProxyAddress_; + TString HostPort_; + + TMaybe<TFormat> InputFormat_ = TFormat::YsonText(); + TMaybe<TFormat> OutputFormat_ = TFormat::YsonText(); + + TString RequestCompression_ = "identity"; + TString ResponseCompression_ = "identity"; }; //////////////////////////////////////////////////////////////////////////////// @@ -172,9 +177,10 @@ public: // 'requestId' and 'hostName' are provided for debug reasons // (they will appear in some error messages). THttpResponse( - IInputStream* socketStream, - const TString& requestId, - const TString& hostName); + TRequestContext context, + IInputStream* socketStream); + + ~THttpResponse(); const THttpHeaders& Headers() const; @@ -196,13 +202,17 @@ private: bool RefreshFrameIfNecessary(); private: - THttpInput HttpInput_; - const TString RequestId_; - const TString HostName_; + class THttpInputWrapped; + +private: + THolder<THttpInputWrapped> HttpInput_; + + const bool Unframe_; + + TRequestContext Context_; int HttpCode_ = 0; TMaybe<TErrorResponse> ErrorResponse_; bool IsExhausted_ = false; - const bool Unframe_; size_t RemainingFrameSize_ = 0; }; @@ -211,18 +221,15 @@ private: class THttpRequest { public: - THttpRequest(); - THttpRequest(const TString& requestId); + THttpRequest(TString requestId, TString hostName, THttpHeader header, TDuration socketTimeout); ~THttpRequest(); TString GetRequestId() const; - void Connect(TString hostName, TDuration socketTimeout = TDuration::Zero()); - - IOutputStream* StartRequest(const THttpHeader& header); + IOutputStream* StartRequest(); void FinishRequest(); - void SmallRequest(const THttpHeader& header, TMaybe<TStringBuf> body); + void SmallRequest(TMaybe<TStringBuf> body); THttpResponse* GetResponseStream(); @@ -233,26 +240,28 @@ public: int GetHttpCode(); private: - IOutputStream* StartRequestImpl(const THttpHeader& header, bool includeParameters); + IOutputStream* StartRequestImpl(bool includeParameters); private: class TRequestStream; private: - TString HostName; - TString RequestId; - TString Url_; + const TRequestContext Context_; + const THttpHeader Header_; + const TString Url_; + const TDuration SocketTimeout_; + TInstant StartTime_; TString LoggedAttributes_; - TConnectionPtr Connection; + TConnectionPtr Connection_; THolder<TRequestStream> RequestStream_; - THolder<TSocketInput> SocketInput; - THolder<THttpResponse> Input; + THolder<TSocketInput> SocketInput_; + THolder<THttpResponse> Input_; - bool LogResponse = false; + bool LogResponse_ = false; }; //////////////////////////////////////////////////////////////////////////////// |