From d94980c0b0ab97879d2eaa40012d0241a7307306 Mon Sep 17 00:00:00 2001 From: helintongh Date: Wed, 1 Nov 2023 18:43:45 +0800 Subject: [PATCH] delete chuncked api --- include/cinatra/coro_http_client.hpp | 50 --------------------------- lang/coro_http_client_introduction.md | 10 ------ 2 files changed, 60 deletions(-) diff --git a/include/cinatra/coro_http_client.hpp b/include/cinatra/coro_http_client.hpp index 4dfca64a..d82a2f45 100644 --- a/include/cinatra/coro_http_client.hpp +++ b/include/cinatra/coro_http_client.hpp @@ -384,56 +384,6 @@ class coro_http_client : public std::enable_shared_from_this { co_return data; } - async_simple::coro::Lazy async_send_ws_chuncked( - std::string msg, uint64_t max_part_size, bool need_mask = true, - opcode op = opcode::text) { - resp_data data{}; - - websocket ws{}; - if (op == opcode::close) { - msg = ws.format_close_payload(close_code::normal, msg.data(), msg.size()); - } - - std::string total_data = ws.encode_frame(msg, op, need_mask); - bool is_first_part = true; - total_data.append(msg); - size_t msg_length = total_data.length(); - int msg_offset = 0; - - while (msg_length > 0) { - std::cout << msg_length << std::endl; - if (msg_length > max_part_size) { - std::string part(total_data.data() + msg_offset, max_part_size); - std::vector buffers{ - asio::buffer(part.data(), max_part_size)}; - auto [ec, _] = co_await async_write(buffers); - if (ec) { - data.net_err = ec; - data.status = 404; - co_return data; - } - msg_length -= max_part_size; - msg_offset += max_part_size; - } - else { - std::string last_part(total_data.data() + msg_offset, msg_length); - std::vector buffers{ - asio::buffer(last_part.data(), last_part.size())}; - auto [ec, _] = co_await async_write(buffers); - if (ec) { - data.net_err = ec; - data.status = 404; - co_return data; - } - - msg_offset += msg_length; - msg_length = 0; - } - } - data.eof = true; - co_return data; - } - async_simple::coro::Lazy async_send_ws_close( std::string msg = "") { return async_send_ws(std::move(msg), false, opcode::close); diff --git a/lang/coro_http_client_introduction.md b/lang/coro_http_client_introduction.md index f2e5512b..3f06ef63 100644 --- a/lang/coro_http_client_introduction.md +++ b/lang/coro_http_client_introduction.md @@ -477,16 +477,6 @@ async_simple::coro::Lazy async_send_ws(std::string msg, async_simple::coro::Lazy async_send_ws_multiple(std::string msg, bool need_mask = true, opcode op = opcode::text); - -/// 分段形式发送websocket 数据 -/// \param msg 要发送的websocket 数据 -/// \param max_part_size 每段发送的数据最大大小 -/// \param need_mask 是否需要对数据进行mask,默认会mask -/// \param op opcode 一般为text、binary或 close 等类型 -async_simple::coro::Lazy async_send_ws_chuncked(std::string msg, - uint64_t max_part_size, - bool need_mask = true, - opcode op = opcode::text); ``` websocket 例子: