Skip to content

Commit

Permalink
fix resize
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed Jan 30, 2024
1 parent f27793b commit 3779324
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/ylt/struct_pack/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ constexpr void STRUCT_PACK_INLINE compile_time_unique(
#if __cpp_lib_string_resize_and_overwrite >= 202110L
template <typename ch>
inline void resize(std::basic_string<ch> &str, std::size_t sz) {
str.resize_and_overwrite(sz, [](ch *, std::size_t sz) {
str.resize_and_overwrite(sz, [sz](ch *, std::size_t) {
return sz;
});
}
Expand Down
9 changes: 7 additions & 2 deletions include/ylt/thirdparty/cinatra/coro_http_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,11 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
req_str_.clear();
total_len_ = 0;
#endif

// clear
head_buf_.consume(head_buf_.size());
chunked_buf_.consume(chunked_buf_.size());
resp_chunk_str_.clear();
}

async_simple::coro::Lazy<resp_data> reconnect(std::string uri) {
Expand Down Expand Up @@ -1774,8 +1779,8 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
head_buf_.consume(head_buf_.size());
size_t header_size = 2;
std::shared_ptr sock = socket_;
auto on_ws_msg = std::move(on_ws_msg_);
auto on_ws_close = std::move(on_ws_close_);
auto on_ws_msg = on_ws_msg_;
auto on_ws_close = on_ws_close_;
asio::streambuf &read_buf = sock->head_buf_;
bool has_init_ssl = false;
#ifdef CINATRA_ENABLE_SSL
Expand Down
2 changes: 1 addition & 1 deletion include/ylt/thirdparty/cinatra/string_resize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace cinatra::detail {
#if __cpp_lib_string_resize_and_overwrite >= 202110L
template <typename ch>
inline void resize(std::basic_string<ch> &str, std::size_t sz) {
str.resize_and_overwrite(sz, [](ch *, std::size_t sz) {
str.resize_and_overwrite(sz, [sz](ch *, std::size_t) {
return sz;
});
}
Expand Down

0 comments on commit 3779324

Please sign in to comment.