From c43edb26eb3fc565ea8703aedabbc2593b722166 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Wed, 10 Jan 2024 19:53:28 +0800 Subject: [PATCH] Fix unexpected inflate failed --- http_client.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/http_client.cpp b/http_client.cpp index fbbc0dd..05e532b 100644 --- a/http_client.cpp +++ b/http_client.cpp @@ -619,14 +619,12 @@ std::string Response::inflate(std::string data) { if (res == Z_STREAM_END) { re += std::string(buf, 10240 - this->zstream.avail_out); break; - } else if (res == Z_BUF_ERROR) { - re += std::string(buf, 10240 - this->zstream.avail_out); - } else if (res != Z_OK) { + } else if (res == Z_STREAM_ERROR || res == Z_NEED_DICT || res == Z_DATA_ERROR || res == Z_MEM_ERROR) { throw std::runtime_error("inflate failed"); } else { re += std::string(buf, 10240 - this->zstream.avail_out); - break; } + if (this->zstream.avail_out != 0) break; } return re; }