From 20a36af9f6a95546e2707ba6a837408d2c016068 Mon Sep 17 00:00:00 2001 From: qicosmos Date: Mon, 8 Jul 2024 15:44:37 +0800 Subject: [PATCH] update out buf logic (#711) --- CMakeLists.txt | 2 +- include/ylt/standalone/cinatra/coro_http_client.hpp | 7 ++++--- include/ylt/version.hpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75ec1426c..c0e42ab5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) project(yaLanTingLibs - VERSION 0.3.4 + VERSION 0.3.5 DESCRIPTION "yaLanTingLibs" HOMEPAGE_URL "https://github.com/alibaba/yalantinglibs" LANGUAGES CXX diff --git a/include/ylt/standalone/cinatra/coro_http_client.hpp b/include/ylt/standalone/cinatra/coro_http_client.hpp index 336ef0cc3..02c0ddc63 100644 --- a/include/ylt/standalone/cinatra/coro_http_client.hpp +++ b/include/ylt/standalone/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/include/ylt/version.hpp b/include/ylt/version.hpp index 650c70e0e..e8b97a70d 100644 --- a/include/ylt/version.hpp +++ b/include/ylt/version.hpp @@ -20,4 +20,4 @@ // YLT_VERSION % 100 is the sub-minor version // YLT_VERSION / 100 % 1000 is the minor version // YLT_VERSION / 100000 is the major version -#define YLT_VERSION 304 // 0.3.4 \ No newline at end of file +#define YLT_VERSION 305 // 0.3.5 \ No newline at end of file