Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/boost/http/concept/buffer_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
12 changes: 6 additions & 6 deletions include/boost/http/io/any_buffer_sink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ any_buffer_sink::write_some(CB buffers)
capy::buffer_param<CB> 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)
Expand All @@ -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<capy::ConstBufferSequence CB>
Expand All @@ -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
Expand Down Expand Up @@ -1121,7 +1121,7 @@ any_buffer_sink::write(CB buffers)
total += n;
}

co_return {{}, total};
co_return {std::error_code(), total};
}

inline auto
Expand Down Expand Up @@ -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<any_buffer_sink>);
Expand Down
8 changes: 4 additions & 4 deletions include/boost/http/io/any_buffer_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ any_buffer_source::read_some(MB buffers)
capy::buffer_param<MB> 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)
Expand All @@ -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<capy::MutableBufferSequence MB>
Expand All @@ -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
Expand All @@ -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<any_buffer_source>);
Expand Down
4 changes: 2 additions & 2 deletions include/boost/http/io/any_read_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -588,7 +588,7 @@ any_read_source::read(MB buffers)
bp.consume(n);
}

co_return {{}, total};
co_return {std::error_code(), total};
}

} // namespace http
Expand Down
4 changes: 2 additions & 2 deletions include/boost/http/io/any_write_sink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -870,7 +870,7 @@ any_write_sink::write(CB buffers)
bp.consume(n);
}

co_return {{}, total};
co_return {std::error_code(), total};
}

template<capy::ConstBufferSequence CB>
Expand Down
2 changes: 1 addition & 1 deletion include/boost/http/io/push_to.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion include/boost/http/metadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
6 changes: 3 additions & 3 deletions include/boost/http/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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())
Expand Down Expand Up @@ -681,7 +681,7 @@ pull(std::span<capy::const_buffer> 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())
Expand Down
4 changes: 2 additions & 2 deletions include/boost/http/serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions include/boost/http/test/buffer_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
8 changes: 4 additions & 4 deletions include/boost/http/test/read_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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};
Expand Down Expand Up @@ -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};
Expand All @@ -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};
Expand Down
10 changes: 5 additions & 5 deletions include/boost/http/test/write_sink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -220,7 +220,7 @@ class write_sink
return {ec, 0};
}

return {{}, n};
return {std::error_code(), n};
}
};
return awaitable{this, buffers};
Expand Down Expand Up @@ -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);
Expand All @@ -299,7 +299,7 @@ class write_sink
if(ec)
return {ec, n};

return {{}, n};
return {std::error_code(), n};
}
};
return awaitable{this, buffers};
Expand Down Expand Up @@ -386,7 +386,7 @@ class write_sink

self_->eof_called_ = true;

return {{}, n};
return {std::error_code(), n};
}
};
return awaitable{this, buffers};
Expand Down
12 changes: 6 additions & 6 deletions test/unit/io/any_buffer_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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};
Expand All @@ -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};
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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<std::size_t> await_resume() { return {{}, 1}; }
io_result<std::size_t> await_resume() { return {std::error_code(), 1}; }
};

// Satisfies BufferSink + WriteSink with suspending operations.
Expand Down
Loading
Loading