diff --git a/include/cinatra/coro_http_client.hpp b/include/cinatra/coro_http_client.hpp index 336ef0cc..02c0ddc6 100644 --- a/include/cinatra/coro_http_client.hpp +++ b/include/cinatra/coro_http_client.hpp @@ -808,6 +808,8 @@ class coro_http_client : public std::enable_shared_from_this { async_download(std::move(uri), std::move(filename), std::move(range))); } + bool is_body_in_out_buf() const { return !out_buf_.empty(); } + void reset() { if (!has_closed()) close_socket(*socket_); @@ -1780,9 +1782,8 @@ class coro_http_client : public std::enable_shared_from_this { bool is_out_buf = !out_buf_.empty(); if (is_out_buf) { if (content_len > 0 && out_buf_.size() < content_len) { - data.status = 404; - data.net_err = std::make_error_code(std::errc::no_buffer_space); - co_return data; + out_buf_ = {}; + is_out_buf = false; } } diff --git a/tests/test_cinatra.cpp b/tests/test_cinatra.cpp index 2abf545a..14b0a9fc 100644 --- a/tests/test_cinatra.cpp +++ b/tests/test_cinatra.cpp @@ -666,8 +666,8 @@ TEST_CASE("test request with out buffer") { auto result = async_simple::coro::syncAwait(ret); std::cout << result.status << "\n"; std::cout << result.net_err.message() << "\n"; - if (result.status == 404) - CHECK(result.net_err == std::errc::no_buffer_space); + CHECK(result.status < 400); + CHECK(!client.is_body_in_out_buf()); } {