Skip to content

Commit

Permalink
Update coro_http_client.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
helintongh committed Jun 24, 2024
1 parent 6179757 commit c560bca
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions include/cinatra/coro_http_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1562,18 +1562,18 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
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;
}
Expand All @@ -1586,9 +1586,10 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
#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;
}
Expand Down Expand Up @@ -2124,8 +2125,8 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
#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
Expand Down

0 comments on commit c560bca

Please sign in to comment.