Reset error codes

fix #478
This commit is contained in:
Vinnie Falco
2017-06-13 07:08:52 -07:00
parent 7d92048c5c
commit ca109693fb
32 changed files with 276 additions and 67 deletions

View File

@@ -1,3 +1,5 @@
PLEASE DON'T FORGET TO "STAR" THIS REPOSITORY :)
When reporting a bug please include the following:
### Version of Beast

View File

@@ -5,6 +5,7 @@ Version 56:
* Call on_chunk when the extension is empty
* HTTP/1.1 is the default version
* Try harder to find Boost (cmake)
* Reset error codes
--------------------------------------------------------------------------------

View File

@@ -72,9 +72,9 @@ In this table:
[`a.init(ec)`]
[]
[
Called immediately after construction. If the function sets an
error code in `ec`, the serialization is aborted and the error
is propagated to the caller.
Called immediately after construction.
The function will ensure that `!ec` is `true` if there was
no error or set to the appropriate error code if there was one.
]
][
[`a.get(ec)`]
@@ -90,6 +90,8 @@ In this table:
if there may be additional buffers returned on a subsequent call,
or `false` if the buffer returned on this call is the last
buffer representing the body.
The function will ensure that `!ec` is `true` if there was
no error or set to the appropriate error code if there was one.
]
][
[`a.finish(ec)`]
@@ -97,7 +99,8 @@ In this table:
[
This function is called after the reader indicates there
are no more buffers remaining.
If `ec` is set, the error will be propagated to the caller.
The function will ensure that `!ec` is `true` if there was
no error or set to the appropriate error code if there was one.
]
][
[`is_body_reader<B>`]
@@ -146,7 +149,11 @@ public:
@param ec Set to the error, if any occurred.
*/
void
init(error_code& ec);
init(error_code& ec)
{
// The specification requires this to indicate "no error"
ec = {};
}
/** Returns the next buffer in the body.

View File

@@ -58,7 +58,8 @@ In the table below:
be set to the content length of the body if known, otherwise
`length` will be equal to `boost::none`. Implementations of
[*BodyWriter] may use this information to optimize allocation.
If `ec` is set, the error will be propagated to the caller.
The function will ensure that `!ec` is `true` if there was
no error or set to the appropriate error code if there was one.
]
][
[`a.put(b,ec)`]
@@ -66,14 +67,16 @@ In the table below:
[
This function is called to append the buffers specified by `b`
into the body representation.
If `ec` is set, the error will be propagated to the caller.
The function will ensure that `!ec` is `true` if there was
no error or set to the appropriate error code if there was one.
]
][
[`a.finish(ec)`]
[]
[
This function is called when no more body octets are remaining.
If `ec` is set, the error will be propagated to the caller.
The function will ensure that `!ec` is `true` if there was
no error or set to the appropriate error code if there was one.
]
][
[`is_body_writer<B>`]
@@ -112,7 +115,11 @@ struct writer
@param ec Set to the error, if any occurred.
*/
void
init(boost::optional<std::uint64_t> content_length, error_code& ec);
init(boost::optional<std::uint64_t> content_length, error_code& ec)
{
// The specification requires this to indicate "no error"
ec = {};
}
/** Store buffers.

View File

@@ -132,7 +132,7 @@ detect_ssl(
"SyncReadStream requirements not met");
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
// Loop until an error occurs or we get a definitive answer
for(;;)
{
@@ -142,7 +142,10 @@ detect_ssl(
// If we got an answer, return it
if(! boost::indeterminate(result))
{
ec = {}; // indicate no error
return result;
}
// The algorithm should never need more than 4 bytes
BOOST_ASSERT(buffer.size() < 4);

View File

@@ -581,6 +581,9 @@ public:
using boost::asio::buffer_cast;
using boost::asio::buffer_size;
// Error codes must be cleared on success
ec = {};
// Keep a running total of how much we wrote
std::size_t bytes_transferred = 0;
@@ -943,6 +946,7 @@ void custom_parser<isRequest>::
on_request(verb method, string_view method_str,
string_view path, int version, error_code& ec)
{
ec = {};
}
template<bool isRequest>
@@ -950,6 +954,7 @@ void custom_parser<isRequest>::
on_response(int status, string_view reason,
int version, error_code& ec)
{
ec = {};
}
template<bool isRequest>
@@ -957,12 +962,14 @@ void custom_parser<isRequest>::
on_field(field f, string_view name,
string_view value, error_code& ec)
{
ec = {};
}
template<bool isRequest>
void custom_parser<isRequest>::
on_header(error_code& ec)
{
ec = {};
}
template<bool isRequest>
@@ -970,12 +977,14 @@ void custom_parser<isRequest>::
on_body(boost::optional<std::uint64_t> const& content_length,
error_code& ec)
{
ec = {};
}
template<bool isRequest>
void custom_parser<isRequest>::
on_data(string_view s, error_code& ec)
{
ec = {};
}
template<bool isRequest>
@@ -983,12 +992,14 @@ void custom_parser<isRequest>::
on_chunk(std::uint64_t size,
string_view extension, error_code& ec)
{
ec = {};
}
template<bool isRequest>
void custom_parser<isRequest>::
on_complete(error_code& ec)
{
ec = {};
}
} // http

View File

@@ -181,6 +181,7 @@ init(error_code& ec)
// The file was opened successfully, get the size
// of the file to know how much we need to read.
ec = {};
remain_ = boost::filesystem::file_size(path_);
}
@@ -201,7 +202,10 @@ get(error_code& ec) ->
// Check for an empty file
if(amount == 0)
{
ec = {};
return boost::none;
}
// Now read the next buffer
auto const nread = fread(buf_, 1, amount, file_);
@@ -229,6 +233,7 @@ get(error_code& ec) ->
// we set this bool to `false` so we will not be called
// again.
//
ec = {};
return {{
const_buffers_type{buf_, nread}, // buffer to return.
remain_ > 0 // `true` if there are more buffers.
@@ -241,6 +246,9 @@ void
file_body::reader::
finish(error_code& ec)
{
// Functions which pass back errors are
// responsible for clearing the error code.
ec = {};
}
// The destructor is always invoked if construction succeeds.
@@ -340,6 +348,9 @@ init(boost::optional<std::uint64_t> const& content_length, error_code& ec)
ec = error_code{errno, system_category()};
return;
}
// Indicate success
ec = {};
}
// This will get called one or more times with body buffers
@@ -367,6 +378,9 @@ put(ConstBufferSequence const& buffers, error_code& ec)
return;
}
}
// Indicate success
ec = {};
}
// Called after writing is done when there's no error.
@@ -375,6 +389,7 @@ void
file_body::writer::
finish(error_code& ec)
{
ec = {};
}
// The destructor is always invoked if construction succeeds

View File

@@ -149,6 +149,7 @@ public:
ec = ec_;
return true;
}
ec = {};
return false;
}
};

View File

@@ -196,6 +196,7 @@ public:
teardown(websocket::teardown_tag,
stream&, boost::system::error_code& ec)
{
ec = {};
}
template<class TeardownHandler>
@@ -367,6 +368,7 @@ read_some(MutableBufferSequence const& buffers,
std::size_t bytes_transferred;
if(in_.b.size() > 0)
{
ec = {};
bytes_transferred = buffer_copy(
buffers, in_.b.data(), read_max_);
in_.b.consume(bytes_transferred);
@@ -478,6 +480,7 @@ write_some(
else
out_.cv.notify_all();
++nwrite;
ec = {};
return bytes_transferred;
}

View File

@@ -72,9 +72,14 @@ public:
auto const n = boost::asio::buffer_copy(
buffers, buffer_prefix(read_max_, cb_));
if(n > 0)
{
ec = {};
cb_ = cb_ + n;
}
else
{
ec = boost::asio::error::eof;
}
return n;
}
@@ -112,8 +117,9 @@ public:
template<class ConstBufferSequence>
std::size_t
write_some(
ConstBufferSequence const& buffers, error_code&)
ConstBufferSequence const& buffers, error_code& ec)
{
ec = {};
using boost::asio::buffer_size;
using boost::asio::buffer_cast;
auto const n = buffer_size(buffers);
@@ -145,6 +151,7 @@ public:
string_iostream& stream,
boost::system::error_code& ec)
{
ec = {};
}
template<class TeardownHandler>

View File

@@ -69,9 +69,14 @@ public:
auto const n = boost::asio::buffer_copy(
buffers, cb_, read_max_);
if(n > 0)
{
ec = {};
cb_ = cb_ + n;
}
else
{
ec = boost::asio::error::eof;
}
return n;
}
@@ -109,8 +114,9 @@ public:
template<class ConstBufferSequence>
std::size_t
write_some(ConstBufferSequence const& buffers,
error_code&)
error_code& ec)
{
ec = {};
return boost::asio::buffer_size(buffers);
}
@@ -133,6 +139,7 @@ public:
string_istream& stream,
boost::system::error_code& ec)
{
ec = {};
}
template<class TeardownHandler>

View File

@@ -91,8 +91,9 @@ public:
template<class ConstBufferSequence>
std::size_t
write_some(
ConstBufferSequence const& buffers, error_code&)
ConstBufferSequence const& buffers, error_code& ec)
{
ec = {};
using boost::asio::buffer_size;
using boost::asio::buffer_cast;
auto const n =
@@ -125,6 +126,7 @@ public:
string_ostream& stream,
boost::system::error_code& ec)
{
ec = {};
}
template<class TeardownHandler>

View File

@@ -225,6 +225,10 @@ read_some(MutableBufferSequence const& buffers,
if(ec)
return 0;
}
else
{
ec = {};
}
auto bytes_transferred =
buffer_copy(buffers, sb_.data());
sb_.consume(bytes_transferred);

View File

@@ -52,8 +52,11 @@ namespace http {
Every callback must be provided by the derived class, or else
a compilation error will be generated. This exemplar shows
the signature and description of the callbacks required in
the derived class. If a callback sets the error code, the error
will be propagated to the caller of the parser.
the derived class.
For each callback, the function will ensure that `!ec` is `true`
if there was no error or set to the appropriate error code if
there was one. If an error is set, the value is propagated to
the caller of the parser.
@tparam isRequest A `bool` indicating whether the parser will be
presented with request or response message.

View File

@@ -110,8 +110,9 @@ struct buffer_body
}
void
init(error_code&)
init(error_code& ec)
{
ec = {};
}
boost::optional<
@@ -125,22 +126,30 @@ struct buffer_body
toggle_ = false;
ec = error::need_buffer;
}
else
{
ec = {};
}
return boost::none;
}
if(body_.data)
{
ec = {};
toggle_ = true;
return {{const_buffers_type{
body_.data, body_.size}, body_.more}};
}
if(body_.more)
ec = error::need_buffer;
else
ec = {};
return boost::none;
}
void
finish(error_code&)
finish(error_code& ec)
{
ec = {};
}
};
#endif
@@ -162,8 +171,9 @@ struct buffer_body
}
void
init(boost::optional<std::uint64_t>, error_code&)
init(boost::optional<std::uint64_t>, error_code& ec)
{
ec = {};
}
template<class ConstBufferSequence>
@@ -179,6 +189,7 @@ struct buffer_body
ec = error::need_buffer;
return;
}
ec = {};
auto const bytes_transferred =
buffer_copy(boost::asio::buffer(
body_.data, body_.size), buffers);
@@ -188,8 +199,9 @@ struct buffer_body
}
void
finish(error_code&)
finish(error_code& ec)
{
ec = {};
}
};
#endif

View File

@@ -389,16 +389,23 @@ protected:
for(;;)
{
if(it == last)
{
ec = {};
return nullptr;
}
if(*it == '\r')
{
if(++it == last)
{
ec = {};
return nullptr;
}
if(*it != '\n')
{
ec = error::bad_line_ending;
return nullptr;
}
ec = {};
return ++it;
}
// VFALCO Should we handle the legacy case
@@ -418,30 +425,43 @@ protected:
for(;;)
{
if(it == last)
{
ec = {};
return nullptr;
}
if(*it == '\r')
{
if(++it == last)
{
ec = {};
return nullptr;
}
if(*it != '\n')
{
ec = error::bad_line_ending;
return nullptr;
}
if(++it == last)
{
ec = {};
return nullptr;
}
if(*it != '\r')
{
++it;
continue;
}
if(++it == last)
{
ec = {};
return nullptr;
}
if(*it != '\n')
{
ec = error::bad_line_ending;
return nullptr;
}
ec = {};
return ++it;
}
// VFALCO Should we handle the legacy case

View File

@@ -61,19 +61,22 @@ struct basic_dynamic_body
}
void
init(error_code&)
init(error_code& ec)
{
ec = {};
}
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec)
{
ec = {};
return {{body_.data(), false}};
}
void
finish(error_code&)
finish(error_code& ec)
{
ec = {};
}
};
#endif
@@ -97,8 +100,9 @@ struct basic_dynamic_body
void
init(boost::optional<
std::uint64_t> const&, error_code&)
std::uint64_t> const&, error_code& ec)
{
ec = {};
}
template<class ConstBufferSequence>
@@ -120,12 +124,14 @@ struct basic_dynamic_body
ec = error::buffer_overflow;
return;
}
ec = {};
body_.commit(buffer_copy(*b, buffers));
}
void
finish(error_code&)
finish(error_code& ec)
{
ec = {};
}
};
#endif

View File

@@ -63,19 +63,22 @@ struct empty_body
}
void
init(error_code&)
init(error_code& ec)
{
ec = {};
}
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec)
{
ec = {};
return boost::none;
}
void
finish(error_code&)
finish(error_code& ec)
{
ec = {};
}
};
#endif
@@ -94,8 +97,9 @@ struct empty_body
void
init(boost::optional<std::uint64_t> const&,
error_code&)
error_code& ec)
{
ec = {};
}
template<class ConstBufferSequence>
@@ -107,8 +111,9 @@ struct empty_body
}
void
finish(error_code&)
finish(error_code& ec)
{
ec = {};
}
};
#endif

View File

@@ -94,7 +94,10 @@ put(ConstBufferSequence const& buffers,
auto const p = buffers.begin();
auto const last = buffers.end();
if(p == last)
{
ec = {};
return 0;
}
if(std::next(p) == last)
{
// single buffer
@@ -196,7 +199,8 @@ loop:
break;
case state::complete:
break;
ec = {};
goto done;
}
if(p < p1 && ! is_done() && eager())
{
@@ -225,6 +229,7 @@ put_eof(error_code& ec)
ec = error::partial_message;
return;
}
ec = {};
return;
}
impl().on_complete(ec);
@@ -789,6 +794,7 @@ do_field(field f,
continue;
}
}
ec = {};
return;
}
@@ -827,6 +833,7 @@ do_field(field f,
return;
}
ec = {};
len_ = v;
f_ |= flagContentLength;
return;
@@ -849,6 +856,7 @@ do_field(field f,
return;
}
ec = {};
auto const v = token_list{value};
auto const p = std::find_if(v.begin(), v.end(),
[&](typename token_list::value_type const& s)
@@ -867,10 +875,12 @@ do_field(field f,
// Upgrade
if(f == field::upgrade)
{
f_ |= flagUpgrade;
ec = {};
f_ |= flagUpgrade;
return;
}
ec = {};
}
} // http

View File

@@ -467,7 +467,6 @@ read_some(
break;
if(ec != http::error::need_more)
break;
ec = {};
do_read:
boost::optional<typename
DynamicBuffer::mutable_buffers_type> b;
@@ -479,7 +478,7 @@ read_some(
catch(std::length_error const&)
{
ec = error::buffer_overflow;
break;
return;
}
auto const bytes_transferred =
stream.read_some(*b, ec);
@@ -489,7 +488,6 @@ read_some(
if(parser.got_some())
{
// caller sees EOF on next read
ec = {};
parser.put_eof(ec);
if(ec)
break;
@@ -570,12 +568,18 @@ read_header(
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
parser.eager(false);
while(! parser.is_header_done())
if(parser.is_header_done())
{
ec = {};
return;
}
do
{
read_some(stream, buffer, parser, ec);
if(ec)
return;
}
while(! parser.is_header_done());
}
template<
@@ -643,12 +647,18 @@ read(
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer requirements not met");
parser.eager(true);
while(! parser.is_done())
if(parser.is_done())
{
ec = {};
return;
}
do
{
read_some(stream, buffer, parser, ec);
if(ec)
return;
}
while(! parser.is_done());
}
template<

View File

@@ -60,7 +60,8 @@ get(error_code& ec, Visit&& visit)
frdinit(std::integral_constant<bool,
isRequest>{});
close_ = m_.has_close() || (
m_.version < 11 && ! m_.has_content_length());
m_.version < 11 &&
! m_.has_content_length());
if(m_.has_chunked())
goto go_init_c;
s_ = do_init;

View File

@@ -56,6 +56,7 @@ class write_some_op
operator()(error_code& ec,
ConstBufferSequence const& buffer)
{
ec = {};
invoked = true;
return op_.s_.async_write_some(
buffer, std::move(op_));
@@ -212,6 +213,7 @@ class write_op
operator()(error_code& ec,
ConstBufferSequence const& buffer)
{
ec = {};
invoked = true;
return op_.s_.async_write_some(
buffer, std::move(op_));
@@ -533,14 +535,16 @@ write_some(SyncWriteStream& stream, serializer<
static_assert(is_body_reader<Body>::value,
"BodyReader requirements not met");
detail::write_some_lambda<SyncWriteStream> f{stream};
if(! sr.is_done())
if(sr.is_done())
{
sr.get(ec, f);
if(ec)
return;
if(f.invoked)
sr.consume(f.bytes_transferred);
ec = {};
return;
}
sr.get(ec, f);
if(ec)
return;
if(f.invoked)
sr.consume(f.bytes_transferred);
}
template<class AsyncWriteStream,
@@ -603,8 +607,13 @@ write_header(SyncWriteStream& stream, serializer<
static_assert(is_body_reader<Body>::value,
"BodyReader requirements not met");
sr.split(true);
if(sr.is_header_done())
{
ec = {};
return;
}
detail::write_lambda<SyncWriteStream> f{stream};
while(! sr.is_header_done())
do
{
sr.get(ec, f);
if(ec)
@@ -612,6 +621,7 @@ write_header(SyncWriteStream& stream, serializer<
BOOST_ASSERT(f.invoked);
sr.consume(f.bytes_transferred);
}
while(! sr.is_header_done());
}
template<class AsyncWriteStream,
@@ -668,8 +678,13 @@ write(SyncWriteStream& stream, serializer<
static_assert(is_sync_write_stream<SyncWriteStream>::value,
"SyncWriteStream requirements not met");
sr.split(false);
if(sr.is_done())
{
ec = {};
return;
}
detail::write_lambda<SyncWriteStream> f{stream};
while(! sr.is_done())
do
{
sr.get(ec, f);
if(ec)
@@ -677,6 +692,7 @@ write(SyncWriteStream& stream, serializer<
if(f.invoked)
sr.consume(f.bytes_transferred);
}
while(! sr.is_done());
if(sr.need_close())
ec = error::end_of_stream;
}
@@ -792,9 +808,12 @@ public:
template<class ConstBufferSequence>
void
operator()(error_code&,
operator()(error_code& ec,
ConstBufferSequence const& buffers) const
{
ec = {};
if(os_.fail())
return;
std::size_t bytes_transferred = 0;
using boost::asio::buffer_cast;
using boost::asio::buffer_size;

View File

@@ -183,8 +183,9 @@ private:
void
on_request(verb method, string_view method_str,
string_view target, int version, error_code&)
string_view target, int version, error_code& ec)
{
ec = {};
m_.target(target);
if(method != verb::unknown)
m_.method(method);
@@ -196,8 +197,9 @@ private:
void
on_response(int code,
string_view reason,
int version, error_code&)
int version, error_code& ec)
{
ec = {};
m_.result(code);
m_.version = version;
m_.reason(reason);
@@ -205,14 +207,16 @@ private:
void
on_field(field name, string_view name_string,
string_view value, error_code&)
string_view value, error_code& ec)
{
ec = {};
m_.insert(name, name_string, value);
}
void
on_header(error_code& ec)
{
ec = {};
}
void
@@ -233,8 +237,9 @@ private:
void
on_chunk(std::uint64_t,
string_view, error_code&)
string_view, error_code& ec)
{
ec = {};
}
void
@@ -242,6 +247,8 @@ private:
{
if(wr_)
wr_->finish(ec);
else
ec = {};
}
};

View File

@@ -63,20 +63,23 @@ struct string_body
}
void
init(error_code&)
init(error_code& ec)
{
ec = {};
}
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code&)
get(error_code& ec)
{
ec = {};
return {{const_buffers_type{
body_.data(), body_.size()}, false}};
}
void
finish(error_code&)
finish(error_code& ec)
{
ec = {};
}
};
#endif
@@ -110,6 +113,7 @@ struct string_body
errc::not_enough_memory);
return;
}
ec = {};
body_.reserve(static_cast<
std::size_t>(*content_length));
}
@@ -133,13 +137,15 @@ struct string_body
ec = error::buffer_overflow;
return;
}
ec = {};
buffer_copy(boost::asio::buffer(
&body_[0] + len, n), buffers);
}
void
finish(error_code&)
finish(error_code& ec)
{
ec = {};
}
};
#endif

View File

@@ -64,19 +64,22 @@ struct string_view_body
}
void
init(error_code&)
init(error_code& ec)
{
ec = {};
}
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec)
{
ec = {};
return {{{body_.data(), body_.size()}, false}};
}
void
finish(error_code&)
finish(error_code& ec)
{
ec = {};
}
};
#endif

View File

@@ -461,6 +461,7 @@ deflate(
}
}
}
ec = {};
out = buffer(
buffer_cast<void*>(out), zs.total_out);
return true;

View File

@@ -148,7 +148,7 @@ do_handshake(response_type* res_p,
return;
do_response(res, key, ec);
if(res_p)
swap(res, *res_p);
*res_p = std::move(res);
}
template<class NextLayer>
@@ -302,6 +302,7 @@ do_response(http::header<false> const& res,
ec = error::handshake_failed;
return;
}
ec = {};
detail::pmd_offer offer;
pmd_read(offer, res);
// VFALCO see if offer satisfies pmd_config_,

View File

@@ -122,6 +122,7 @@ public:
relay<true>(upstream.client, downstream.server, buffer, ec,
[&](header<true, fields>& h, error_code& ec)
{
ec = {};
h.erase("Content-Length");
h.replace("Transfer-Encoding", "chunked");
});

View File

@@ -212,6 +212,7 @@ print_cxx14(message<isRequest, Body, Fields> const& m)
sr.get(ec,
[&sr](error_code& ec, auto const& buffer)
{
ec = {};
std::cout << buffers(buffer);
sr.consume(boost::asio::buffer_size(buffer));
});
@@ -238,6 +239,7 @@ struct lambda
template<class ConstBufferSequence>
void operator()(error_code& ec, ConstBufferSequence const& buffer) const
{
ec = {};
std::cout << buffers(buffer);
sr.consume(boost::asio::buffer_size(buffer));
}
@@ -278,6 +280,7 @@ split_print_cxx14(message<isRequest, Body, Fields> const& m)
sr.get(ec,
[&sr](error_code& ec, auto const& buffer)
{
ec = {};
std::cout << buffers(buffer);
sr.consume(boost::asio::buffer_size(buffer));
});
@@ -291,6 +294,7 @@ split_print_cxx14(message<isRequest, Body, Fields> const& m)
sr.get(ec,
[&sr](error_code& ec, auto const& buffer)
{
ec = {};
std::cout << buffers(buffer);
sr.consume(boost::asio::buffer_size(buffer));
});

View File

@@ -166,50 +166,58 @@ public:
void
on_request(verb, string_view,
string_view, int, error_code&)
string_view, int, error_code& ec)
{
ec = {};
}
void
on_response(int,
string_view,
int, error_code&)
int, error_code& ec)
{
ec = {};
}
void
on_field(field,
string_view, string_view, error_code&)
string_view, string_view, error_code& ec)
{
ec = {};
}
void
on_header(error_code& ec)
{
ec = {};
}
void
on_body(boost::optional<std::uint64_t> const&,
error_code&)
error_code& ec)
{
ec = {};
}
void
on_data(string_view,
error_code& ec)
{
ec = {};
}
void
on_chunk(std::uint64_t,
string_view,
error_code&)
error_code& ec)
{
ec = {};
}
void
on_complete(error_code&)
on_complete(error_code& ec)
{
ec = {};
}
};

View File

@@ -58,6 +58,8 @@ public:
got_on_begin = true;
if(fc_)
fc_->fail(ec);
else
ec = {};
}
void
@@ -72,6 +74,8 @@ public:
got_on_begin = true;
if(fc_)
fc_->fail(ec);
else
ec = {};
}
void
@@ -81,6 +85,8 @@ public:
got_on_field = true;
if(fc_)
fc_->fail(ec);
else
ec = {};
}
void
@@ -89,6 +95,8 @@ public:
got_on_header = true;
if(fc_)
fc_->fail(ec);
else
ec = {};
}
void
@@ -101,6 +109,8 @@ public:
static_cast<bool>(content_length_);
if(fc_)
fc_->fail(ec);
else
ec = {};
}
void
@@ -110,6 +120,8 @@ public:
body.append(s.data(), s.size());
if(fc_)
fc_->fail(ec);
else
ec = {};
}
void
@@ -119,6 +131,8 @@ public:
got_on_chunk = true;
if(fc_)
fc_->fail(ec);
else
ec = {};
}
void
@@ -127,6 +141,8 @@ public:
got_on_complete = true;
if(fc_)
fc_->fail(ec);
else
ec = {};
}
};

View File

@@ -55,20 +55,23 @@ public:
}
void
init(error_code&)
init(error_code& ec)
{
ec = {};
}
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code&)
get(error_code& ec)
{
ec = {};
return {{const_buffers_type{
body_.data(), body_.size()}, false}};
}
void
finish(error_code&)
finish(error_code& ec)
{
ec = {};
}
};
};
@@ -107,13 +110,15 @@ public:
}
void
init(error_code&)
init(error_code& ec)
{
ec = {};
}
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code&)
get(error_code& ec)
{
ec = {};
body_.read = true;
return get(
std::integral_constant<bool, isSplit>{},
@@ -121,8 +126,9 @@ public:
}
void
finish(error_code&)
finish(error_code& ec)
{
ec = {};
}
private: