From e6a4cf4bd1b937a6f48795e3f950c14bfc6a82fe Mon Sep 17 00:00:00 2001 From: qicosmos Date: Tue, 22 Aug 2023 18:59:18 +0800 Subject: [PATCH] [coro_http_client][fix] release buf (#424) --- include/ylt/thirdparty/cinatra/coro_http_client.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/ylt/thirdparty/cinatra/coro_http_client.hpp b/include/ylt/thirdparty/cinatra/coro_http_client.hpp index 7ab016975..716f4cd84 100644 --- a/include/ylt/thirdparty/cinatra/coro_http_client.hpp +++ b/include/ylt/thirdparty/cinatra/coro_http_client.hpp @@ -215,7 +215,13 @@ class coro_http_client { #endif // return body_, the user will own body's lifetime. - std::string release_buf() { return std::move(body_); } + std::string release_buf() { + if (body_.empty()) { + return std::move(resp_chunk_str_); + } + + return std::move(body_); + } // only make socket connet(or handshake) to the host async_simple::coro::Lazy connect(std::string uri) {