From c560bca5e30cd924e8d7f93e00bed4fe658e8c3f Mon Sep 17 00:00:00 2001 From: helintong Date: Mon, 24 Jun 2024 17:37:19 +0800 Subject: [PATCH] Update coro_http_client.hpp --- include/cinatra/coro_http_client.hpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/include/cinatra/coro_http_client.hpp b/include/cinatra/coro_http_client.hpp index faf0961b..fc2f28ee 100644 --- a/include/cinatra/coro_http_client.hpp +++ b/include/cinatra/coro_http_client.hpp @@ -1562,18 +1562,18 @@ class coro_http_client : public std::enable_shared_from_this { std::string_view reply(data_ptr, content_len); #ifdef CINATRA_ENABLE_GZIP if (encoding_type_ == content_encoding::gzip) { - std::string unziped_str; - bool r = gzip_codec::uncompress(reply, unziped_str); + uncompressed_str_.clear(); + bool r = gzip_codec::uncompress(reply, uncompressed_str_); if (r) - data.resp_body = unziped_str; + data.resp_body = uncompressed_str_; else data.resp_body = reply; } else if (encoding_type_ == content_encoding::deflate) { - std::string inflate_str; - bool r = gzip_codec::inflate(reply, inflate_str); + uncompressed_str_.clear(); + bool r = gzip_codec::inflate(reply, uncompressed_str_); if (r) - data.resp_body = inflate_str; + data.resp_body = uncompressed_str_; else data.resp_body = reply; } @@ -1586,9 +1586,10 @@ class coro_http_client : public std::enable_shared_from_this { #endif #ifdef CINATRA_ENABLE_BROTLI { - bool r = br_codec::brotli_decompress(reply, unbr_str_); + uncompressed_str_.clear(); + bool r = br_codec::brotli_decompress(reply, uncompressed_str_); if (r) - data.resp_body = unbr_str_; + data.resp_body = uncompressed_str_; else data.resp_body = reply; } @@ -2124,8 +2125,8 @@ class coro_http_client : public std::enable_shared_from_this { #endif content_encoding encoding_type_ = content_encoding::none; -#ifdef CINATRA_ENABLE_BROTLI - std::string unbr_str_; +#if defined(CINATRA_ENABLE_BROTLI) || defined(CINATRA_ENABLE_GZIP) + std::string uncompressed_str_; #endif #ifdef BENCHMARK_TEST