diff --git a/include/boost/http/concept/buffer_source.hpp b/include/boost/http/concept/buffer_source.hpp index ca5d1278..6c400e82 100644 --- a/include/boost/http/concept/buffer_source.hpp +++ b/include/boost/http/concept/buffer_source.hpp @@ -90,7 +90,7 @@ namespace http { { auto [ec, bufs] = co_await source.pull( arr ); if( ec == cond::eof ) - co_return {{}, total}; + co_return {std::error_code(), total}; if( ec ) co_return {ec, total}; auto [write_ec, n] = co_await stream.write_some( bufs ); diff --git a/include/boost/http/io/any_buffer_sink.hpp b/include/boost/http/io/any_buffer_sink.hpp index f1fbdfa5..e5c66ee6 100644 --- a/include/boost/http/io/any_buffer_sink.hpp +++ b/include/boost/http/io/any_buffer_sink.hpp @@ -1045,7 +1045,7 @@ any_buffer_sink::write_some(CB buffers) capy::buffer_param bp(buffers); auto src = bp.data(); if(src.empty()) - co_return {{}, 0}; + co_return {std::error_code(), 0}; // Native WriteSink path if(vt_->construct_write_some_awaitable) @@ -1061,14 +1061,14 @@ any_buffer_sink::write_some(CB buffers) co_return {ec, 0}; dst_bufs = prepare(arr); if(dst_bufs.empty()) - co_return {{}, 0}; + co_return {std::error_code(), 0}; } auto n = capy::buffer_copy(dst_bufs, src); auto [ec] = co_await commit(n); if(ec) co_return {ec, 0}; - co_return {{}, n}; + co_return {std::error_code(), n}; } template @@ -1093,7 +1093,7 @@ any_buffer_sink::write(CB buffers) co_return {ec, total}; bp.consume(n); } - co_return {{}, total}; + co_return {std::error_code(), total}; } // Synthesized path: prepare + capy::buffer_copy + commit @@ -1121,7 +1121,7 @@ any_buffer_sink::write(CB buffers) total += n; } - co_return {{}, total}; + co_return {std::error_code(), total}; } inline auto @@ -1246,7 +1246,7 @@ any_buffer_sink::write_eof(CB buffers) if(ec) co_return {ec, total}; - co_return {{}, total}; + co_return {std::error_code(), total}; } static_assert(BufferSink); diff --git a/include/boost/http/io/any_buffer_source.hpp b/include/boost/http/io/any_buffer_source.hpp index 83d25a5b..eaaea086 100644 --- a/include/boost/http/io/any_buffer_source.hpp +++ b/include/boost/http/io/any_buffer_source.hpp @@ -761,7 +761,7 @@ any_buffer_source::read_some(MB buffers) capy::buffer_param bp(buffers); auto dest = bp.data(); if(dest.empty()) - co_return {{}, 0}; + co_return {std::error_code(), 0}; // Native ReadSource path if(vt_->construct_read_some_awaitable) @@ -775,7 +775,7 @@ any_buffer_source::read_some(MB buffers) auto n = capy::buffer_copy(dest, bufs); consume(n); - co_return {{}, n}; + co_return {std::error_code(), n}; } template @@ -800,7 +800,7 @@ any_buffer_source::read(MB buffers) co_return {ec, total}; bp.consume(n); } - co_return {{}, total}; + co_return {std::error_code(), total}; } // Synthesized path: pull + capy::buffer_copy + consume @@ -822,7 +822,7 @@ any_buffer_source::read(MB buffers) bp.consume(n); } - co_return {{}, total}; + co_return {std::error_code(), total}; } static_assert(BufferSource); diff --git a/include/boost/http/io/any_read_source.hpp b/include/boost/http/io/any_read_source.hpp index 5c229896..7c775f4a 100644 --- a/include/boost/http/io/any_read_source.hpp +++ b/include/boost/http/io/any_read_source.hpp @@ -506,7 +506,7 @@ any_read_source::read_some(MB buffers) await_resume() { if(ba_.to_span().empty()) - return {{}, 0}; + return {std::error_code(), 0}; struct guard { any_read_source* self; @@ -588,7 +588,7 @@ any_read_source::read(MB buffers) bp.consume(n); } - co_return {{}, total}; + co_return {std::error_code(), total}; } } // namespace http diff --git a/include/boost/http/io/any_write_sink.hpp b/include/boost/http/io/any_write_sink.hpp index 4dbabfa0..44a895a2 100644 --- a/include/boost/http/io/any_write_sink.hpp +++ b/include/boost/http/io/any_write_sink.hpp @@ -834,7 +834,7 @@ any_write_sink::write_some(CB buffers) await_resume() { if(ba_.to_span().empty()) - return {{}, 0}; + return {std::error_code(), 0}; struct guard { any_write_sink* self; @@ -870,7 +870,7 @@ any_write_sink::write(CB buffers) bp.consume(n); } - co_return {{}, total}; + co_return {std::error_code(), total}; } template diff --git a/include/boost/http/io/push_to.hpp b/include/boost/http/io/push_to.hpp index dc7820a1..d02261d0 100644 --- a/include/boost/http/io/push_to.hpp +++ b/include/boost/http/io/push_to.hpp @@ -134,7 +134,7 @@ push_to(Src& source, Stream& stream) { auto [ec, bufs] = co_await source.pull(arr); if(ec == capy::cond::eof) - co_return {{}, total}; + co_return {std::error_code(), total}; if(ec) co_return {ec, total}; diff --git a/include/boost/http/metadata.hpp b/include/boost/http/metadata.hpp index 26fe98c6..376a338f 100644 --- a/include/boost/http/metadata.hpp +++ b/include/boost/http/metadata.hpp @@ -21,7 +21,7 @@ namespace http { /** Identifies the payload type of a message. */ -enum class payload +enum class payload : unsigned char { /** This message has no payload. */ diff --git a/include/boost/http/parser.hpp b/include/boost/http/parser.hpp index 28b40f24..3dcf351c 100644 --- a/include/boost/http/parser.hpp +++ b/include/boost/http/parser.hpp @@ -601,7 +601,7 @@ parser:: read(Stream& stream, MB buffers) { if(capy::buffer_empty(buffers)) - co_return {{}, 0}; + co_return {std::error_code(), 0}; std::size_t total = 0; capy::consuming_buffers dest(buffers); @@ -622,7 +622,7 @@ read(Stream& stream, MB buffers) dest.consume(copied); if(capy::buffer_empty(dest.data())) - co_return {{}, total}; + co_return {std::error_code(), total}; } if(is_complete()) @@ -681,7 +681,7 @@ pull(std::span dest) std::size_t count = (std::min)(body_data.size(), dest.size()); for(std::size_t i = 0; i < count; ++i) dest[i] = body_data[i]; - co_return {{}, dest.first(count)}; + co_return {std::error_code(), dest.first(count)}; } if(pr_->is_complete()) diff --git a/include/boost/http/serializer.hpp b/include/boost/http/serializer.hpp index 322223cd..a9bce4e0 100644 --- a/include/boost/http/serializer.hpp +++ b/include/boost/http/serializer.hpp @@ -825,7 +825,7 @@ class serializer::sink } } - co_return {{}, total}; + co_return {std::error_code(), total}; } /** Write final body data and signal end-of-stream. @@ -877,7 +877,7 @@ class serializer::sink co_return {ec2, n}; } - co_return {{}, n}; + co_return {std::error_code(), n}; } /** Signal end-of-stream with no additional data. diff --git a/include/boost/http/test/buffer_source.hpp b/include/boost/http/test/buffer_source.hpp index 5fb6fe4c..cd3d93ee 100644 --- a/include/boost/http/test/buffer_source.hpp +++ b/include/boost/http/test/buffer_source.hpp @@ -192,14 +192,14 @@ class buffer_source std::size_t to_return = (std::min)(avail, self_->max_pull_size_); if(dest_.empty()) - return {{}, {}}; + return {std::error_code(), {}}; // Fill a single buffer descriptor dest_[0] = capy::make_buffer( self_->data_.data() + self_->pos_, to_return); - return {{}, dest_.first(1)}; + return {std::error_code(), dest_.first(1)}; } }; return awaitable{this, dest}; diff --git a/include/boost/http/test/read_source.hpp b/include/boost/http/test/read_source.hpp index aea5c840..94385b16 100644 --- a/include/boost/http/test/read_source.hpp +++ b/include/boost/http/test/read_source.hpp @@ -163,7 +163,7 @@ class read_source await_resume() { if(capy::buffer_empty(buffers_)) - return {{}, 0}; + return {std::error_code(), 0}; if(canceled_) return {capy::error::canceled, 0}; @@ -181,7 +181,7 @@ class read_source auto src = capy::make_buffer(self_->data_.data() + self_->pos_, avail); std::size_t const n = capy::buffer_copy(buffers_, src); self_->pos_ += n; - return {{}, n}; + return {std::error_code(), n}; } }; return awaitable{this, buffers}; @@ -238,7 +238,7 @@ class read_source await_resume() { if(capy::buffer_empty(buffers_)) - return {{}, 0}; + return {std::error_code(), 0}; if(canceled_) return {capy::error::canceled, 0}; @@ -257,7 +257,7 @@ class read_source if(n < capy::buffer_size(buffers_)) return {capy::error::eof, n}; - return {{}, n}; + return {std::error_code(), n}; } }; return awaitable{this, buffers}; diff --git a/include/boost/http/test/write_sink.hpp b/include/boost/http/test/write_sink.hpp index 68f2d96d..00cc2c0f 100644 --- a/include/boost/http/test/write_sink.hpp +++ b/include/boost/http/test/write_sink.hpp @@ -196,7 +196,7 @@ class write_sink await_resume() { if(capy::buffer_empty(buffers_)) - return {{}, 0}; + return {std::error_code(), 0}; if(canceled_) return {capy::error::canceled, 0}; @@ -220,7 +220,7 @@ class write_sink return {ec, 0}; } - return {{}, n}; + return {std::error_code(), n}; } }; return awaitable{this, buffers}; @@ -288,7 +288,7 @@ class write_sink std::size_t n = capy::buffer_size(buffers_); if(n == 0) - return {{}, 0}; + return {std::error_code(), 0}; std::size_t const old_size = self_->data_.size(); self_->data_.resize(old_size + n); @@ -299,7 +299,7 @@ class write_sink if(ec) return {ec, n}; - return {{}, n}; + return {std::error_code(), n}; } }; return awaitable{this, buffers}; @@ -386,7 +386,7 @@ class write_sink self_->eof_called_ = true; - return {{}, n}; + return {std::error_code(), n}; } }; return awaitable{this, buffers}; diff --git a/test/unit/io/any_buffer_sink.cpp b/test/unit/io/any_buffer_sink.cpp index bd61f847..ec4f4fe9 100644 --- a/test/unit/io/any_buffer_sink.cpp +++ b/test/unit/io/any_buffer_sink.cpp @@ -169,7 +169,7 @@ class buffer_write_sink { self_->write_api_used_ = true; if(buffer_empty(buffers_)) - return {{}, 0}; + return {std::error_code(), 0}; auto ec = self_->f_.maybe_fail(); if(ec) return {ec, 0}; @@ -178,7 +178,7 @@ class buffer_write_sink self_->data_.resize(old_size + n); buffer_copy(make_buffer( self_->data_.data() + old_size, n), buffers_, n); - return {{}, n}; + return {std::error_code(), n}; } }; return awaitable{this, buffers}; @@ -204,12 +204,12 @@ class buffer_write_sink if(ec) return {ec, 0}; std::size_t n = buffer_size(buffers_); - if(n == 0) return {{}, 0}; + if(n == 0) return {std::error_code(), 0}; std::size_t const old_size = self_->data_.size(); self_->data_.resize(old_size + n); buffer_copy(make_buffer( self_->data_.data() + old_size, n), buffers_); - return {{}, n}; + return {std::error_code(), n}; } }; return awaitable{this, buffers}; @@ -243,7 +243,7 @@ class buffer_write_sink self_->data_.data() + old_size, n), buffers_); } self_->eof_called_ = true; - return {{}, n}; + return {std::error_code(), n}; } }; return awaitable{this, buffers}; @@ -299,7 +299,7 @@ struct resuming_size_awaitable std::coroutine_handle<> await_suspend(std::coroutine_handle<> h, io_env const*) noexcept { return h; } - io_result await_resume() { return {{}, 1}; } + io_result await_resume() { return {std::error_code(), 1}; } }; // Satisfies BufferSink + WriteSink with suspending operations. diff --git a/test/unit/io/any_buffer_source.cpp b/test/unit/io/any_buffer_source.cpp index 56f41654..ca37f7c0 100644 --- a/test/unit/io/any_buffer_source.cpp +++ b/test/unit/io/any_buffer_source.cpp @@ -115,12 +115,12 @@ class buffer_read_source std::size_t to_return = (std::min)(avail, self_->max_pull_size_); if(dest_.empty()) - return {{}, {}}; + return {std::error_code(), {}}; dest_[0] = make_buffer( self_->data_.data() + self_->pos_, to_return); - return {{}, dest_.first(1)}; + return {std::error_code(), dest_.first(1)}; } }; return awaitable{this, dest}; @@ -146,7 +146,7 @@ class buffer_read_source { self_->read_api_used_ = true; if(buffer_empty(buffers_)) - return {{}, 0}; + return {std::error_code(), 0}; auto ec = self_->f_.maybe_fail(); if(ec) return {ec, 0}; @@ -161,7 +161,7 @@ class buffer_read_source self_->data_.data() + self_->pos_, avail); std::size_t const n = buffer_copy(buffers_, src); self_->pos_ += n; - return {{}, n}; + return {std::error_code(), n}; } }; return awaitable{this, buffers}; @@ -184,7 +184,7 @@ class buffer_read_source { self_->read_api_used_ = true; if(buffer_empty(buffers_)) - return {{}, 0}; + return {std::error_code(), 0}; auto ec = self_->f_.maybe_fail(); if(ec) return {ec, 0}; @@ -200,7 +200,7 @@ class buffer_read_source if(n < buffer_size(buffers_)) return {capy::error::eof, n}; - return {{}, n}; + return {std::error_code(), n}; } }; return awaitable{this, buffers}; @@ -221,9 +221,9 @@ struct resuming_pull_awaitable await_resume() { if(dest_.empty()) - return {{}, {}}; + return {std::error_code(), {}}; dest_[0] = make_buffer(data_, 3); - return {{}, dest_.first(1)}; + return {std::error_code(), dest_.first(1)}; } }; @@ -233,7 +233,7 @@ struct resuming_io_awaitable std::coroutine_handle<> await_suspend(std::coroutine_handle<> h, io_env const*) noexcept { return h; } - io_result await_resume() { return {{}, 3}; } + io_result await_resume() { return {std::error_code(), 3}; } }; // Satisfies BufferSource + ReadSource with suspending operations. diff --git a/test/unit/io/any_read_source.cpp b/test/unit/io/any_read_source.cpp index 0e3c412b..82d15e7a 100644 --- a/test/unit/io/any_read_source.cpp +++ b/test/unit/io/any_read_source.cpp @@ -48,7 +48,7 @@ struct pending_source_awaitable std::coroutine_handle<> await_suspend(std::coroutine_handle<>, io_env const*) { return std::noop_coroutine(); } io_result await_resume() - { return {{}, 0}; } + { return {std::error_code(), 0}; } }; struct pending_read_source @@ -70,7 +70,7 @@ struct resuming_source_awaitable std::coroutine_handle<> await_suspend(std::coroutine_handle<> h, io_env const*) noexcept { return h; } - io_result await_resume() { return {{}, 5}; } + io_result await_resume() { return {std::error_code(), 5}; } }; struct resuming_read_source diff --git a/test/unit/io/any_write_sink.cpp b/test/unit/io/any_write_sink.cpp index 94533dab..2aebc914 100644 --- a/test/unit/io/any_write_sink.cpp +++ b/test/unit/io/any_write_sink.cpp @@ -48,7 +48,7 @@ struct pending_sink_awaitable std::coroutine_handle<> await_suspend(std::coroutine_handle<>, io_env const*) { return std::noop_coroutine(); } io_result await_resume() - { return {{}, 0}; } + { return {std::error_code(), 0}; } }; struct pending_sink_eof_awaitable @@ -89,7 +89,7 @@ struct resuming_sink_awaitable std::coroutine_handle<> await_suspend(std::coroutine_handle<> h, io_env const*) noexcept { return h; } - io_result await_resume() { return {{}, 1}; } + io_result await_resume() { return {std::error_code(), 1}; } }; struct resuming_sink_eof_awaitable