Skip to content

Commit

Permalink
fix by review
Browse files Browse the repository at this point in the history
  • Loading branch information
helintongh committed Jun 20, 2024
1 parent c18c875 commit bd1fc40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions include/cinatra/coro_http_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,12 +1590,9 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {

#ifdef CINATRA_ENABLE_BROTLI
if (encoding_type_ == content_encoding::br) {
std::string unbr_str;
bool r = br_codec::brotli_decompress(reply, unbr_str);
if (r) {
data.resp_body = unbr_str;
data.br_data = unbr_str;
}
bool r = br_codec::brotli_decompress(reply, unbr_str_);
if (r)
data.resp_body = unbr_str_;
else
data.resp_body = reply;

Expand Down Expand Up @@ -2133,6 +2130,10 @@ 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_;
#endif

#ifdef BENCHMARK_TEST
bool stop_bench_ = false;
size_t total_len_ = 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cinatra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ TEST_CASE("test brotli type") {

auto result = async_simple::coro::syncAwait(client.async_post(
"http://127.0.0.1:9001/get", ziped_str, req_content_type::none, headers));
CHECK(result.br_data == "ok");
CHECK(result.resp_body == "ok");
server.stop();
}
#endif
Expand Down

0 comments on commit bd1fc40

Please sign in to comment.