diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-08-21 13:42:32 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-08-21 13:56:09 +0300 |
commit | 3391579f10b1bab2f82c4ea4921c794ab67e0d8b (patch) | |
tree | 0fb21299329110e5597fbf857ab902e9cc84afd9 /library/cpp/http/push_parser/http_parser.cpp | |
parent | 84b94f3b97a138085aafa50e6b06a49a8d742256 (diff) | |
download | ydb-3391579f10b1bab2f82c4ea4921c794ab67e0d8b.tar.gz |
Intermediate changes
Diffstat (limited to 'library/cpp/http/push_parser/http_parser.cpp')
-rw-r--r-- | library/cpp/http/push_parser/http_parser.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/library/cpp/http/push_parser/http_parser.cpp b/library/cpp/http/push_parser/http_parser.cpp index b69818c15c..a646b349a3 100644 --- a/library/cpp/http/push_parser/http_parser.cpp +++ b/library/cpp/http/push_parser/http_parser.cpp @@ -261,13 +261,9 @@ void THttpParser::OnEof() { throw THttpException() << TStringBuf("incompleted http response"); } -bool THttpParser::DecodeContent() { - if (!DecodeContent_) { - return false; - } - +bool THttpParser::DecodeContent(TString& decodedContent) const { if (!ContentEncoding_ || ContentEncoding_ == "identity" || ContentEncoding_ == "none") { - DecodedContent_ = Content_; + decodedContent = Content_; return false; } @@ -277,7 +273,7 @@ bool THttpParser::DecodeContent() { if (!GzipAllowMultipleStreams_) { decompressor.SetAllowMultipleStreams(false); } - DecodedContent_ = decompressor.ReadAll(); + decodedContent = decompressor.ReadAll(); } else if (ContentEncoding_ == "deflate") { //https://tools.ietf.org/html/rfc1950 @@ -291,14 +287,14 @@ bool THttpParser::DecodeContent() { } try { - DecodedContent_ = TZLibDecompress(&in, definitelyNoZlibHeader ? ZLib::Raw : ZLib::ZLib).ReadAll(); + decodedContent = TZLibDecompress(&in, definitelyNoZlibHeader ? ZLib::Raw : ZLib::ZLib).ReadAll(); } catch(...) { if (definitelyNoZlibHeader) { throw; } TMemoryInput retryInput(Content_.data(), Content_.size()); - DecodedContent_ = TZLibDecompress(&retryInput, ZLib::Raw).ReadAll(); + decodedContent = TZLibDecompress(&retryInput, ZLib::Raw).ReadAll(); } } else if (ContentEncoding_.StartsWith("z-")) { // opposite for library/cpp/http/io/stream.h @@ -313,13 +309,13 @@ bool THttpParser::DecodeContent() { throw THttpParseException() << "Unsupported content-encoding method: " << exc.AsStrBuf(); } NBlockCodecs::TDecodedInput decoder(&in, codec); - DecodedContent_ = decoder.ReadAll(); + decodedContent = decoder.ReadAll(); } else if (ContentEncoding_ == "lz4") { const auto* codec = NBlockCodecs::Codec(TStringBuf(ContentEncoding_)); - DecodedContent_ = codec->Decode(Content_); + decodedContent = codec->Decode(Content_); } else if (ContentEncoding_ == "br") { TBrotliDecompress decoder(&in); - DecodedContent_ = decoder.ReadAll(); + decodedContent = decoder.ReadAll(); } else { throw THttpParseException() << "Unsupported content-encoding method: " << ContentEncoding_; } |