mirror of
https://github.com/boostorg/beast.git
synced 2025-08-02 22:34:32 +02:00
2
.github/ISSUE_TEMPLATE.md
vendored
2
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,3 +1,5 @@
|
|||||||
|
PLEASE DON'T FORGET TO "STAR" THIS REPOSITORY :)
|
||||||
|
|
||||||
When reporting a bug please include the following:
|
When reporting a bug please include the following:
|
||||||
|
|
||||||
### Version of Beast
|
### Version of Beast
|
||||||
|
@@ -5,6 +5,7 @@ Version 56:
|
|||||||
* Call on_chunk when the extension is empty
|
* Call on_chunk when the extension is empty
|
||||||
* HTTP/1.1 is the default version
|
* HTTP/1.1 is the default version
|
||||||
* Try harder to find Boost (cmake)
|
* Try harder to find Boost (cmake)
|
||||||
|
* Reset error codes
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -72,9 +72,9 @@ In this table:
|
|||||||
[`a.init(ec)`]
|
[`a.init(ec)`]
|
||||||
[]
|
[]
|
||||||
[
|
[
|
||||||
Called immediately after construction. If the function sets an
|
Called immediately after construction.
|
||||||
error code in `ec`, the serialization is aborted and the error
|
The function will ensure that `!ec` is `true` if there was
|
||||||
is propagated to the caller.
|
no error or set to the appropriate error code if there was one.
|
||||||
]
|
]
|
||||||
][
|
][
|
||||||
[`a.get(ec)`]
|
[`a.get(ec)`]
|
||||||
@@ -90,6 +90,8 @@ In this table:
|
|||||||
if there may be additional buffers returned on a subsequent call,
|
if there may be additional buffers returned on a subsequent call,
|
||||||
or `false` if the buffer returned on this call is the last
|
or `false` if the buffer returned on this call is the last
|
||||||
buffer representing the body.
|
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)`]
|
[`a.finish(ec)`]
|
||||||
@@ -97,7 +99,8 @@ In this table:
|
|||||||
[
|
[
|
||||||
This function is called after the reader indicates there
|
This function is called after the reader indicates there
|
||||||
are no more buffers remaining.
|
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>`]
|
[`is_body_reader<B>`]
|
||||||
@@ -146,7 +149,11 @@ public:
|
|||||||
@param ec Set to the error, if any occurred.
|
@param ec Set to the error, if any occurred.
|
||||||
*/
|
*/
|
||||||
void
|
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.
|
/** Returns the next buffer in the body.
|
||||||
|
|
||||||
|
@@ -58,7 +58,8 @@ In the table below:
|
|||||||
be set to the content length of the body if known, otherwise
|
be set to the content length of the body if known, otherwise
|
||||||
`length` will be equal to `boost::none`. Implementations of
|
`length` will be equal to `boost::none`. Implementations of
|
||||||
[*BodyWriter] may use this information to optimize allocation.
|
[*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)`]
|
[`a.put(b,ec)`]
|
||||||
@@ -66,14 +67,16 @@ In the table below:
|
|||||||
[
|
[
|
||||||
This function is called to append the buffers specified by `b`
|
This function is called to append the buffers specified by `b`
|
||||||
into the body representation.
|
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)`]
|
[`a.finish(ec)`]
|
||||||
[]
|
[]
|
||||||
[
|
[
|
||||||
This function is called when no more body octets are remaining.
|
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>`]
|
[`is_body_writer<B>`]
|
||||||
@@ -112,7 +115,11 @@ struct writer
|
|||||||
@param ec Set to the error, if any occurred.
|
@param ec Set to the error, if any occurred.
|
||||||
*/
|
*/
|
||||||
void
|
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.
|
/** Store buffers.
|
||||||
|
|
||||||
|
@@ -142,7 +142,10 @@ detect_ssl(
|
|||||||
|
|
||||||
// If we got an answer, return it
|
// If we got an answer, return it
|
||||||
if(! boost::indeterminate(result))
|
if(! boost::indeterminate(result))
|
||||||
|
{
|
||||||
|
ec = {}; // indicate no error
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// The algorithm should never need more than 4 bytes
|
// The algorithm should never need more than 4 bytes
|
||||||
BOOST_ASSERT(buffer.size() < 4);
|
BOOST_ASSERT(buffer.size() < 4);
|
||||||
|
@@ -581,6 +581,9 @@ public:
|
|||||||
using boost::asio::buffer_cast;
|
using boost::asio::buffer_cast;
|
||||||
using boost::asio::buffer_size;
|
using boost::asio::buffer_size;
|
||||||
|
|
||||||
|
// Error codes must be cleared on success
|
||||||
|
ec = {};
|
||||||
|
|
||||||
// Keep a running total of how much we wrote
|
// Keep a running total of how much we wrote
|
||||||
std::size_t bytes_transferred = 0;
|
std::size_t bytes_transferred = 0;
|
||||||
|
|
||||||
@@ -943,6 +946,7 @@ void custom_parser<isRequest>::
|
|||||||
on_request(verb method, string_view method_str,
|
on_request(verb method, string_view method_str,
|
||||||
string_view path, int version, error_code& ec)
|
string_view path, int version, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool isRequest>
|
template<bool isRequest>
|
||||||
@@ -950,6 +954,7 @@ void custom_parser<isRequest>::
|
|||||||
on_response(int status, string_view reason,
|
on_response(int status, string_view reason,
|
||||||
int version, error_code& ec)
|
int version, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool isRequest>
|
template<bool isRequest>
|
||||||
@@ -957,12 +962,14 @@ void custom_parser<isRequest>::
|
|||||||
on_field(field f, string_view name,
|
on_field(field f, string_view name,
|
||||||
string_view value, error_code& ec)
|
string_view value, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool isRequest>
|
template<bool isRequest>
|
||||||
void custom_parser<isRequest>::
|
void custom_parser<isRequest>::
|
||||||
on_header(error_code& ec)
|
on_header(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool isRequest>
|
template<bool isRequest>
|
||||||
@@ -970,12 +977,14 @@ void custom_parser<isRequest>::
|
|||||||
on_body(boost::optional<std::uint64_t> const& content_length,
|
on_body(boost::optional<std::uint64_t> const& content_length,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool isRequest>
|
template<bool isRequest>
|
||||||
void custom_parser<isRequest>::
|
void custom_parser<isRequest>::
|
||||||
on_data(string_view s, error_code& ec)
|
on_data(string_view s, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool isRequest>
|
template<bool isRequest>
|
||||||
@@ -983,12 +992,14 @@ void custom_parser<isRequest>::
|
|||||||
on_chunk(std::uint64_t size,
|
on_chunk(std::uint64_t size,
|
||||||
string_view extension, error_code& ec)
|
string_view extension, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool isRequest>
|
template<bool isRequest>
|
||||||
void custom_parser<isRequest>::
|
void custom_parser<isRequest>::
|
||||||
on_complete(error_code& ec)
|
on_complete(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // http
|
} // http
|
||||||
|
@@ -181,6 +181,7 @@ init(error_code& ec)
|
|||||||
|
|
||||||
// The file was opened successfully, get the size
|
// The file was opened successfully, get the size
|
||||||
// of the file to know how much we need to read.
|
// of the file to know how much we need to read.
|
||||||
|
ec = {};
|
||||||
remain_ = boost::filesystem::file_size(path_);
|
remain_ = boost::filesystem::file_size(path_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +202,10 @@ get(error_code& ec) ->
|
|||||||
|
|
||||||
// Check for an empty file
|
// Check for an empty file
|
||||||
if(amount == 0)
|
if(amount == 0)
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
return boost::none;
|
return boost::none;
|
||||||
|
}
|
||||||
|
|
||||||
// Now read the next buffer
|
// Now read the next buffer
|
||||||
auto const nread = fread(buf_, 1, amount, file_);
|
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
|
// we set this bool to `false` so we will not be called
|
||||||
// again.
|
// again.
|
||||||
//
|
//
|
||||||
|
ec = {};
|
||||||
return {{
|
return {{
|
||||||
const_buffers_type{buf_, nread}, // buffer to return.
|
const_buffers_type{buf_, nread}, // buffer to return.
|
||||||
remain_ > 0 // `true` if there are more buffers.
|
remain_ > 0 // `true` if there are more buffers.
|
||||||
@@ -241,6 +246,9 @@ void
|
|||||||
file_body::reader::
|
file_body::reader::
|
||||||
finish(error_code& ec)
|
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.
|
// 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()};
|
ec = error_code{errno, system_category()};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Indicate success
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will get called one or more times with body buffers
|
// This will get called one or more times with body buffers
|
||||||
@@ -367,6 +378,9 @@ put(ConstBufferSequence const& buffers, error_code& ec)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Indicate success
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called after writing is done when there's no error.
|
// Called after writing is done when there's no error.
|
||||||
@@ -375,6 +389,7 @@ void
|
|||||||
file_body::writer::
|
file_body::writer::
|
||||||
finish(error_code& ec)
|
finish(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// The destructor is always invoked if construction succeeds
|
// The destructor is always invoked if construction succeeds
|
||||||
|
@@ -149,6 +149,7 @@ public:
|
|||||||
ec = ec_;
|
ec = ec_;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
ec = {};
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -196,6 +196,7 @@ public:
|
|||||||
teardown(websocket::teardown_tag,
|
teardown(websocket::teardown_tag,
|
||||||
stream&, boost::system::error_code& ec)
|
stream&, boost::system::error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TeardownHandler>
|
template<class TeardownHandler>
|
||||||
@@ -367,6 +368,7 @@ read_some(MutableBufferSequence const& buffers,
|
|||||||
std::size_t bytes_transferred;
|
std::size_t bytes_transferred;
|
||||||
if(in_.b.size() > 0)
|
if(in_.b.size() > 0)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
bytes_transferred = buffer_copy(
|
bytes_transferred = buffer_copy(
|
||||||
buffers, in_.b.data(), read_max_);
|
buffers, in_.b.data(), read_max_);
|
||||||
in_.b.consume(bytes_transferred);
|
in_.b.consume(bytes_transferred);
|
||||||
@@ -478,6 +480,7 @@ write_some(
|
|||||||
else
|
else
|
||||||
out_.cv.notify_all();
|
out_.cv.notify_all();
|
||||||
++nwrite;
|
++nwrite;
|
||||||
|
ec = {};
|
||||||
return bytes_transferred;
|
return bytes_transferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -72,9 +72,14 @@ public:
|
|||||||
auto const n = boost::asio::buffer_copy(
|
auto const n = boost::asio::buffer_copy(
|
||||||
buffers, buffer_prefix(read_max_, cb_));
|
buffers, buffer_prefix(read_max_, cb_));
|
||||||
if(n > 0)
|
if(n > 0)
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
cb_ = cb_ + n;
|
cb_ = cb_ + n;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ec = boost::asio::error::eof;
|
ec = boost::asio::error::eof;
|
||||||
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +117,9 @@ public:
|
|||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
std::size_t
|
std::size_t
|
||||||
write_some(
|
write_some(
|
||||||
ConstBufferSequence const& buffers, error_code&)
|
ConstBufferSequence const& buffers, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
using boost::asio::buffer_size;
|
using boost::asio::buffer_size;
|
||||||
using boost::asio::buffer_cast;
|
using boost::asio::buffer_cast;
|
||||||
auto const n = buffer_size(buffers);
|
auto const n = buffer_size(buffers);
|
||||||
@@ -145,6 +151,7 @@ public:
|
|||||||
string_iostream& stream,
|
string_iostream& stream,
|
||||||
boost::system::error_code& ec)
|
boost::system::error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TeardownHandler>
|
template<class TeardownHandler>
|
||||||
|
@@ -69,9 +69,14 @@ public:
|
|||||||
auto const n = boost::asio::buffer_copy(
|
auto const n = boost::asio::buffer_copy(
|
||||||
buffers, cb_, read_max_);
|
buffers, cb_, read_max_);
|
||||||
if(n > 0)
|
if(n > 0)
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
cb_ = cb_ + n;
|
cb_ = cb_ + n;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ec = boost::asio::error::eof;
|
ec = boost::asio::error::eof;
|
||||||
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +114,9 @@ public:
|
|||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
std::size_t
|
std::size_t
|
||||||
write_some(ConstBufferSequence const& buffers,
|
write_some(ConstBufferSequence const& buffers,
|
||||||
error_code&)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
return boost::asio::buffer_size(buffers);
|
return boost::asio::buffer_size(buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +139,7 @@ public:
|
|||||||
string_istream& stream,
|
string_istream& stream,
|
||||||
boost::system::error_code& ec)
|
boost::system::error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TeardownHandler>
|
template<class TeardownHandler>
|
||||||
|
@@ -91,8 +91,9 @@ public:
|
|||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
std::size_t
|
std::size_t
|
||||||
write_some(
|
write_some(
|
||||||
ConstBufferSequence const& buffers, error_code&)
|
ConstBufferSequence const& buffers, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
using boost::asio::buffer_size;
|
using boost::asio::buffer_size;
|
||||||
using boost::asio::buffer_cast;
|
using boost::asio::buffer_cast;
|
||||||
auto const n =
|
auto const n =
|
||||||
@@ -125,6 +126,7 @@ public:
|
|||||||
string_ostream& stream,
|
string_ostream& stream,
|
||||||
boost::system::error_code& ec)
|
boost::system::error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TeardownHandler>
|
template<class TeardownHandler>
|
||||||
|
@@ -225,6 +225,10 @@ read_some(MutableBufferSequence const& buffers,
|
|||||||
if(ec)
|
if(ec)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
|
}
|
||||||
auto bytes_transferred =
|
auto bytes_transferred =
|
||||||
buffer_copy(buffers, sb_.data());
|
buffer_copy(buffers, sb_.data());
|
||||||
sb_.consume(bytes_transferred);
|
sb_.consume(bytes_transferred);
|
||||||
|
@@ -52,8 +52,11 @@ namespace http {
|
|||||||
Every callback must be provided by the derived class, or else
|
Every callback must be provided by the derived class, or else
|
||||||
a compilation error will be generated. This exemplar shows
|
a compilation error will be generated. This exemplar shows
|
||||||
the signature and description of the callbacks required in
|
the signature and description of the callbacks required in
|
||||||
the derived class. If a callback sets the error code, the error
|
the derived class.
|
||||||
will be propagated to the caller of the parser.
|
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
|
@tparam isRequest A `bool` indicating whether the parser will be
|
||||||
presented with request or response message.
|
presented with request or response message.
|
||||||
|
@@ -110,8 +110,9 @@ struct buffer_body
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init(error_code&)
|
init(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<
|
boost::optional<
|
||||||
@@ -125,22 +126,30 @@ struct buffer_body
|
|||||||
toggle_ = false;
|
toggle_ = false;
|
||||||
ec = error::need_buffer;
|
ec = error::need_buffer;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
|
}
|
||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
if(body_.data)
|
if(body_.data)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
toggle_ = true;
|
toggle_ = true;
|
||||||
return {{const_buffers_type{
|
return {{const_buffers_type{
|
||||||
body_.data, body_.size}, body_.more}};
|
body_.data, body_.size}, body_.more}};
|
||||||
}
|
}
|
||||||
if(body_.more)
|
if(body_.more)
|
||||||
ec = error::need_buffer;
|
ec = error::need_buffer;
|
||||||
|
else
|
||||||
|
ec = {};
|
||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finish(error_code&)
|
finish(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -162,8 +171,9 @@ struct buffer_body
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init(boost::optional<std::uint64_t>, error_code&)
|
init(boost::optional<std::uint64_t>, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
@@ -179,6 +189,7 @@ struct buffer_body
|
|||||||
ec = error::need_buffer;
|
ec = error::need_buffer;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ec = {};
|
||||||
auto const bytes_transferred =
|
auto const bytes_transferred =
|
||||||
buffer_copy(boost::asio::buffer(
|
buffer_copy(boost::asio::buffer(
|
||||||
body_.data, body_.size), buffers);
|
body_.data, body_.size), buffers);
|
||||||
@@ -188,8 +199,9 @@ struct buffer_body
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finish(error_code&)
|
finish(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@@ -389,16 +389,23 @@ protected:
|
|||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if(it == last)
|
if(it == last)
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
if(*it == '\r')
|
if(*it == '\r')
|
||||||
{
|
{
|
||||||
if(++it == last)
|
if(++it == last)
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
if(*it != '\n')
|
if(*it != '\n')
|
||||||
{
|
{
|
||||||
ec = error::bad_line_ending;
|
ec = error::bad_line_ending;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
ec = {};
|
||||||
return ++it;
|
return ++it;
|
||||||
}
|
}
|
||||||
// VFALCO Should we handle the legacy case
|
// VFALCO Should we handle the legacy case
|
||||||
@@ -418,30 +425,43 @@ protected:
|
|||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if(it == last)
|
if(it == last)
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
if(*it == '\r')
|
if(*it == '\r')
|
||||||
{
|
{
|
||||||
if(++it == last)
|
if(++it == last)
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
if(*it != '\n')
|
if(*it != '\n')
|
||||||
{
|
{
|
||||||
ec = error::bad_line_ending;
|
ec = error::bad_line_ending;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if(++it == last)
|
if(++it == last)
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
if(*it != '\r')
|
if(*it != '\r')
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(++it == last)
|
if(++it == last)
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
if(*it != '\n')
|
if(*it != '\n')
|
||||||
{
|
{
|
||||||
ec = error::bad_line_ending;
|
ec = error::bad_line_ending;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
ec = {};
|
||||||
return ++it;
|
return ++it;
|
||||||
}
|
}
|
||||||
// VFALCO Should we handle the legacy case
|
// VFALCO Should we handle the legacy case
|
||||||
|
@@ -61,19 +61,22 @@ struct basic_dynamic_body
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init(error_code&)
|
init(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::pair<const_buffers_type, bool>>
|
boost::optional<std::pair<const_buffers_type, bool>>
|
||||||
get(error_code& ec)
|
get(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
return {{body_.data(), false}};
|
return {{body_.data(), false}};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finish(error_code&)
|
finish(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -97,8 +100,9 @@ struct basic_dynamic_body
|
|||||||
|
|
||||||
void
|
void
|
||||||
init(boost::optional<
|
init(boost::optional<
|
||||||
std::uint64_t> const&, error_code&)
|
std::uint64_t> const&, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
@@ -120,12 +124,14 @@ struct basic_dynamic_body
|
|||||||
ec = error::buffer_overflow;
|
ec = error::buffer_overflow;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ec = {};
|
||||||
body_.commit(buffer_copy(*b, buffers));
|
body_.commit(buffer_copy(*b, buffers));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finish(error_code&)
|
finish(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@@ -63,19 +63,22 @@ struct empty_body
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init(error_code&)
|
init(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::pair<const_buffers_type, bool>>
|
boost::optional<std::pair<const_buffers_type, bool>>
|
||||||
get(error_code& ec)
|
get(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finish(error_code&)
|
finish(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -94,8 +97,9 @@ struct empty_body
|
|||||||
|
|
||||||
void
|
void
|
||||||
init(boost::optional<std::uint64_t> const&,
|
init(boost::optional<std::uint64_t> const&,
|
||||||
error_code&)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
@@ -107,8 +111,9 @@ struct empty_body
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finish(error_code&)
|
finish(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@@ -94,7 +94,10 @@ put(ConstBufferSequence const& buffers,
|
|||||||
auto const p = buffers.begin();
|
auto const p = buffers.begin();
|
||||||
auto const last = buffers.end();
|
auto const last = buffers.end();
|
||||||
if(p == last)
|
if(p == last)
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
if(std::next(p) == last)
|
if(std::next(p) == last)
|
||||||
{
|
{
|
||||||
// single buffer
|
// single buffer
|
||||||
@@ -196,7 +199,8 @@ loop:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case state::complete:
|
case state::complete:
|
||||||
break;
|
ec = {};
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
if(p < p1 && ! is_done() && eager())
|
if(p < p1 && ! is_done() && eager())
|
||||||
{
|
{
|
||||||
@@ -225,6 +229,7 @@ put_eof(error_code& ec)
|
|||||||
ec = error::partial_message;
|
ec = error::partial_message;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ec = {};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
impl().on_complete(ec);
|
impl().on_complete(ec);
|
||||||
@@ -789,6 +794,7 @@ do_field(field f,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ec = {};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -827,6 +833,7 @@ do_field(field f,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ec = {};
|
||||||
len_ = v;
|
len_ = v;
|
||||||
f_ |= flagContentLength;
|
f_ |= flagContentLength;
|
||||||
return;
|
return;
|
||||||
@@ -849,6 +856,7 @@ do_field(field f,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ec = {};
|
||||||
auto const v = token_list{value};
|
auto const v = token_list{value};
|
||||||
auto const p = std::find_if(v.begin(), v.end(),
|
auto const p = std::find_if(v.begin(), v.end(),
|
||||||
[&](typename token_list::value_type const& s)
|
[&](typename token_list::value_type const& s)
|
||||||
@@ -867,10 +875,12 @@ do_field(field f,
|
|||||||
// Upgrade
|
// Upgrade
|
||||||
if(f == field::upgrade)
|
if(f == field::upgrade)
|
||||||
{
|
{
|
||||||
f_ |= flagUpgrade;
|
|
||||||
ec = {};
|
ec = {};
|
||||||
|
f_ |= flagUpgrade;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // http
|
} // http
|
||||||
|
@@ -467,7 +467,6 @@ read_some(
|
|||||||
break;
|
break;
|
||||||
if(ec != http::error::need_more)
|
if(ec != http::error::need_more)
|
||||||
break;
|
break;
|
||||||
ec = {};
|
|
||||||
do_read:
|
do_read:
|
||||||
boost::optional<typename
|
boost::optional<typename
|
||||||
DynamicBuffer::mutable_buffers_type> b;
|
DynamicBuffer::mutable_buffers_type> b;
|
||||||
@@ -479,7 +478,7 @@ read_some(
|
|||||||
catch(std::length_error const&)
|
catch(std::length_error const&)
|
||||||
{
|
{
|
||||||
ec = error::buffer_overflow;
|
ec = error::buffer_overflow;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
auto const bytes_transferred =
|
auto const bytes_transferred =
|
||||||
stream.read_some(*b, ec);
|
stream.read_some(*b, ec);
|
||||||
@@ -489,7 +488,6 @@ read_some(
|
|||||||
if(parser.got_some())
|
if(parser.got_some())
|
||||||
{
|
{
|
||||||
// caller sees EOF on next read
|
// caller sees EOF on next read
|
||||||
ec = {};
|
|
||||||
parser.put_eof(ec);
|
parser.put_eof(ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
break;
|
break;
|
||||||
@@ -570,12 +568,18 @@ read_header(
|
|||||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||||
"DynamicBuffer requirements not met");
|
"DynamicBuffer requirements not met");
|
||||||
parser.eager(false);
|
parser.eager(false);
|
||||||
while(! parser.is_header_done())
|
if(parser.is_header_done())
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
do
|
||||||
{
|
{
|
||||||
read_some(stream, buffer, parser, ec);
|
read_some(stream, buffer, parser, ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
while(! parser.is_header_done());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
template<
|
||||||
@@ -643,12 +647,18 @@ read(
|
|||||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||||
"DynamicBuffer requirements not met");
|
"DynamicBuffer requirements not met");
|
||||||
parser.eager(true);
|
parser.eager(true);
|
||||||
while(! parser.is_done())
|
if(parser.is_done())
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
do
|
||||||
{
|
{
|
||||||
read_some(stream, buffer, parser, ec);
|
read_some(stream, buffer, parser, ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
while(! parser.is_done());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
template<
|
||||||
|
@@ -60,7 +60,8 @@ get(error_code& ec, Visit&& visit)
|
|||||||
frdinit(std::integral_constant<bool,
|
frdinit(std::integral_constant<bool,
|
||||||
isRequest>{});
|
isRequest>{});
|
||||||
close_ = m_.has_close() || (
|
close_ = m_.has_close() || (
|
||||||
m_.version < 11 && ! m_.has_content_length());
|
m_.version < 11 &&
|
||||||
|
! m_.has_content_length());
|
||||||
if(m_.has_chunked())
|
if(m_.has_chunked())
|
||||||
goto go_init_c;
|
goto go_init_c;
|
||||||
s_ = do_init;
|
s_ = do_init;
|
||||||
|
@@ -56,6 +56,7 @@ class write_some_op
|
|||||||
operator()(error_code& ec,
|
operator()(error_code& ec,
|
||||||
ConstBufferSequence const& buffer)
|
ConstBufferSequence const& buffer)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
invoked = true;
|
invoked = true;
|
||||||
return op_.s_.async_write_some(
|
return op_.s_.async_write_some(
|
||||||
buffer, std::move(op_));
|
buffer, std::move(op_));
|
||||||
@@ -212,6 +213,7 @@ class write_op
|
|||||||
operator()(error_code& ec,
|
operator()(error_code& ec,
|
||||||
ConstBufferSequence const& buffer)
|
ConstBufferSequence const& buffer)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
invoked = true;
|
invoked = true;
|
||||||
return op_.s_.async_write_some(
|
return op_.s_.async_write_some(
|
||||||
buffer, std::move(op_));
|
buffer, std::move(op_));
|
||||||
@@ -533,15 +535,17 @@ write_some(SyncWriteStream& stream, serializer<
|
|||||||
static_assert(is_body_reader<Body>::value,
|
static_assert(is_body_reader<Body>::value,
|
||||||
"BodyReader requirements not met");
|
"BodyReader requirements not met");
|
||||||
detail::write_some_lambda<SyncWriteStream> f{stream};
|
detail::write_some_lambda<SyncWriteStream> f{stream};
|
||||||
if(! sr.is_done())
|
if(sr.is_done())
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
sr.get(ec, f);
|
sr.get(ec, f);
|
||||||
if(ec)
|
if(ec)
|
||||||
return;
|
return;
|
||||||
if(f.invoked)
|
if(f.invoked)
|
||||||
sr.consume(f.bytes_transferred);
|
sr.consume(f.bytes_transferred);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
template<class AsyncWriteStream,
|
template<class AsyncWriteStream,
|
||||||
bool isRequest, class Body, class Fields,
|
bool isRequest, class Body, class Fields,
|
||||||
@@ -603,8 +607,13 @@ write_header(SyncWriteStream& stream, serializer<
|
|||||||
static_assert(is_body_reader<Body>::value,
|
static_assert(is_body_reader<Body>::value,
|
||||||
"BodyReader requirements not met");
|
"BodyReader requirements not met");
|
||||||
sr.split(true);
|
sr.split(true);
|
||||||
|
if(sr.is_header_done())
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
detail::write_lambda<SyncWriteStream> f{stream};
|
detail::write_lambda<SyncWriteStream> f{stream};
|
||||||
while(! sr.is_header_done())
|
do
|
||||||
{
|
{
|
||||||
sr.get(ec, f);
|
sr.get(ec, f);
|
||||||
if(ec)
|
if(ec)
|
||||||
@@ -612,6 +621,7 @@ write_header(SyncWriteStream& stream, serializer<
|
|||||||
BOOST_ASSERT(f.invoked);
|
BOOST_ASSERT(f.invoked);
|
||||||
sr.consume(f.bytes_transferred);
|
sr.consume(f.bytes_transferred);
|
||||||
}
|
}
|
||||||
|
while(! sr.is_header_done());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class AsyncWriteStream,
|
template<class AsyncWriteStream,
|
||||||
@@ -668,8 +678,13 @@ write(SyncWriteStream& stream, serializer<
|
|||||||
static_assert(is_sync_write_stream<SyncWriteStream>::value,
|
static_assert(is_sync_write_stream<SyncWriteStream>::value,
|
||||||
"SyncWriteStream requirements not met");
|
"SyncWriteStream requirements not met");
|
||||||
sr.split(false);
|
sr.split(false);
|
||||||
|
if(sr.is_done())
|
||||||
|
{
|
||||||
|
ec = {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
detail::write_lambda<SyncWriteStream> f{stream};
|
detail::write_lambda<SyncWriteStream> f{stream};
|
||||||
while(! sr.is_done())
|
do
|
||||||
{
|
{
|
||||||
sr.get(ec, f);
|
sr.get(ec, f);
|
||||||
if(ec)
|
if(ec)
|
||||||
@@ -677,6 +692,7 @@ write(SyncWriteStream& stream, serializer<
|
|||||||
if(f.invoked)
|
if(f.invoked)
|
||||||
sr.consume(f.bytes_transferred);
|
sr.consume(f.bytes_transferred);
|
||||||
}
|
}
|
||||||
|
while(! sr.is_done());
|
||||||
if(sr.need_close())
|
if(sr.need_close())
|
||||||
ec = error::end_of_stream;
|
ec = error::end_of_stream;
|
||||||
}
|
}
|
||||||
@@ -792,9 +808,12 @@ public:
|
|||||||
|
|
||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
void
|
void
|
||||||
operator()(error_code&,
|
operator()(error_code& ec,
|
||||||
ConstBufferSequence const& buffers) const
|
ConstBufferSequence const& buffers) const
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
|
if(os_.fail())
|
||||||
|
return;
|
||||||
std::size_t bytes_transferred = 0;
|
std::size_t bytes_transferred = 0;
|
||||||
using boost::asio::buffer_cast;
|
using boost::asio::buffer_cast;
|
||||||
using boost::asio::buffer_size;
|
using boost::asio::buffer_size;
|
||||||
|
@@ -183,8 +183,9 @@ private:
|
|||||||
|
|
||||||
void
|
void
|
||||||
on_request(verb method, string_view method_str,
|
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);
|
m_.target(target);
|
||||||
if(method != verb::unknown)
|
if(method != verb::unknown)
|
||||||
m_.method(method);
|
m_.method(method);
|
||||||
@@ -196,8 +197,9 @@ private:
|
|||||||
void
|
void
|
||||||
on_response(int code,
|
on_response(int code,
|
||||||
string_view reason,
|
string_view reason,
|
||||||
int version, error_code&)
|
int version, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
m_.result(code);
|
m_.result(code);
|
||||||
m_.version = version;
|
m_.version = version;
|
||||||
m_.reason(reason);
|
m_.reason(reason);
|
||||||
@@ -205,14 +207,16 @@ private:
|
|||||||
|
|
||||||
void
|
void
|
||||||
on_field(field name, string_view name_string,
|
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);
|
m_.insert(name, name_string, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_header(error_code& ec)
|
on_header(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -233,8 +237,9 @@ private:
|
|||||||
|
|
||||||
void
|
void
|
||||||
on_chunk(std::uint64_t,
|
on_chunk(std::uint64_t,
|
||||||
string_view, error_code&)
|
string_view, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -242,6 +247,8 @@ private:
|
|||||||
{
|
{
|
||||||
if(wr_)
|
if(wr_)
|
||||||
wr_->finish(ec);
|
wr_->finish(ec);
|
||||||
|
else
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -63,20 +63,23 @@ struct string_body
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init(error_code&)
|
init(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::pair<const_buffers_type, bool>>
|
boost::optional<std::pair<const_buffers_type, bool>>
|
||||||
get(error_code&)
|
get(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
return {{const_buffers_type{
|
return {{const_buffers_type{
|
||||||
body_.data(), body_.size()}, false}};
|
body_.data(), body_.size()}, false}};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finish(error_code&)
|
finish(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -110,6 +113,7 @@ struct string_body
|
|||||||
errc::not_enough_memory);
|
errc::not_enough_memory);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ec = {};
|
||||||
body_.reserve(static_cast<
|
body_.reserve(static_cast<
|
||||||
std::size_t>(*content_length));
|
std::size_t>(*content_length));
|
||||||
}
|
}
|
||||||
@@ -133,13 +137,15 @@ struct string_body
|
|||||||
ec = error::buffer_overflow;
|
ec = error::buffer_overflow;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ec = {};
|
||||||
buffer_copy(boost::asio::buffer(
|
buffer_copy(boost::asio::buffer(
|
||||||
&body_[0] + len, n), buffers);
|
&body_[0] + len, n), buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finish(error_code&)
|
finish(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@@ -64,19 +64,22 @@ struct string_view_body
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init(error_code&)
|
init(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::pair<const_buffers_type, bool>>
|
boost::optional<std::pair<const_buffers_type, bool>>
|
||||||
get(error_code& ec)
|
get(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
return {{{body_.data(), body_.size()}, false}};
|
return {{{body_.data(), body_.size()}, false}};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finish(error_code&)
|
finish(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@@ -461,6 +461,7 @@ deflate(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ec = {};
|
||||||
out = buffer(
|
out = buffer(
|
||||||
buffer_cast<void*>(out), zs.total_out);
|
buffer_cast<void*>(out), zs.total_out);
|
||||||
return true;
|
return true;
|
||||||
|
@@ -148,7 +148,7 @@ do_handshake(response_type* res_p,
|
|||||||
return;
|
return;
|
||||||
do_response(res, key, ec);
|
do_response(res, key, ec);
|
||||||
if(res_p)
|
if(res_p)
|
||||||
swap(res, *res_p);
|
*res_p = std::move(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
@@ -302,6 +302,7 @@ do_response(http::header<false> const& res,
|
|||||||
ec = error::handshake_failed;
|
ec = error::handshake_failed;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ec = {};
|
||||||
detail::pmd_offer offer;
|
detail::pmd_offer offer;
|
||||||
pmd_read(offer, res);
|
pmd_read(offer, res);
|
||||||
// VFALCO see if offer satisfies pmd_config_,
|
// VFALCO see if offer satisfies pmd_config_,
|
||||||
|
@@ -122,6 +122,7 @@ public:
|
|||||||
relay<true>(upstream.client, downstream.server, buffer, ec,
|
relay<true>(upstream.client, downstream.server, buffer, ec,
|
||||||
[&](header<true, fields>& h, error_code& ec)
|
[&](header<true, fields>& h, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
h.erase("Content-Length");
|
h.erase("Content-Length");
|
||||||
h.replace("Transfer-Encoding", "chunked");
|
h.replace("Transfer-Encoding", "chunked");
|
||||||
});
|
});
|
||||||
|
@@ -212,6 +212,7 @@ print_cxx14(message<isRequest, Body, Fields> const& m)
|
|||||||
sr.get(ec,
|
sr.get(ec,
|
||||||
[&sr](error_code& ec, auto const& buffer)
|
[&sr](error_code& ec, auto const& buffer)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
std::cout << buffers(buffer);
|
std::cout << buffers(buffer);
|
||||||
sr.consume(boost::asio::buffer_size(buffer));
|
sr.consume(boost::asio::buffer_size(buffer));
|
||||||
});
|
});
|
||||||
@@ -238,6 +239,7 @@ struct lambda
|
|||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
void operator()(error_code& ec, ConstBufferSequence const& buffer) const
|
void operator()(error_code& ec, ConstBufferSequence const& buffer) const
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
std::cout << buffers(buffer);
|
std::cout << buffers(buffer);
|
||||||
sr.consume(boost::asio::buffer_size(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.get(ec,
|
||||||
[&sr](error_code& ec, auto const& buffer)
|
[&sr](error_code& ec, auto const& buffer)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
std::cout << buffers(buffer);
|
std::cout << buffers(buffer);
|
||||||
sr.consume(boost::asio::buffer_size(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.get(ec,
|
||||||
[&sr](error_code& ec, auto const& buffer)
|
[&sr](error_code& ec, auto const& buffer)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
std::cout << buffers(buffer);
|
std::cout << buffers(buffer);
|
||||||
sr.consume(boost::asio::buffer_size(buffer));
|
sr.consume(boost::asio::buffer_size(buffer));
|
||||||
});
|
});
|
||||||
|
@@ -166,50 +166,58 @@ public:
|
|||||||
|
|
||||||
void
|
void
|
||||||
on_request(verb, string_view,
|
on_request(verb, string_view,
|
||||||
string_view, int, error_code&)
|
string_view, int, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_response(int,
|
on_response(int,
|
||||||
string_view,
|
string_view,
|
||||||
int, error_code&)
|
int, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_field(field,
|
on_field(field,
|
||||||
string_view, string_view, error_code&)
|
string_view, string_view, error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_header(error_code& ec)
|
on_header(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_body(boost::optional<std::uint64_t> const&,
|
on_body(boost::optional<std::uint64_t> const&,
|
||||||
error_code&)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_data(string_view,
|
on_data(string_view,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_chunk(std::uint64_t,
|
on_chunk(std::uint64_t,
|
||||||
string_view,
|
string_view,
|
||||||
error_code&)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_complete(error_code&)
|
on_complete(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -58,6 +58,8 @@ public:
|
|||||||
got_on_begin = true;
|
got_on_begin = true;
|
||||||
if(fc_)
|
if(fc_)
|
||||||
fc_->fail(ec);
|
fc_->fail(ec);
|
||||||
|
else
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -72,6 +74,8 @@ public:
|
|||||||
got_on_begin = true;
|
got_on_begin = true;
|
||||||
if(fc_)
|
if(fc_)
|
||||||
fc_->fail(ec);
|
fc_->fail(ec);
|
||||||
|
else
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -81,6 +85,8 @@ public:
|
|||||||
got_on_field = true;
|
got_on_field = true;
|
||||||
if(fc_)
|
if(fc_)
|
||||||
fc_->fail(ec);
|
fc_->fail(ec);
|
||||||
|
else
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -89,6 +95,8 @@ public:
|
|||||||
got_on_header = true;
|
got_on_header = true;
|
||||||
if(fc_)
|
if(fc_)
|
||||||
fc_->fail(ec);
|
fc_->fail(ec);
|
||||||
|
else
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -101,6 +109,8 @@ public:
|
|||||||
static_cast<bool>(content_length_);
|
static_cast<bool>(content_length_);
|
||||||
if(fc_)
|
if(fc_)
|
||||||
fc_->fail(ec);
|
fc_->fail(ec);
|
||||||
|
else
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -110,6 +120,8 @@ public:
|
|||||||
body.append(s.data(), s.size());
|
body.append(s.data(), s.size());
|
||||||
if(fc_)
|
if(fc_)
|
||||||
fc_->fail(ec);
|
fc_->fail(ec);
|
||||||
|
else
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -119,6 +131,8 @@ public:
|
|||||||
got_on_chunk = true;
|
got_on_chunk = true;
|
||||||
if(fc_)
|
if(fc_)
|
||||||
fc_->fail(ec);
|
fc_->fail(ec);
|
||||||
|
else
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -127,6 +141,8 @@ public:
|
|||||||
got_on_complete = true;
|
got_on_complete = true;
|
||||||
if(fc_)
|
if(fc_)
|
||||||
fc_->fail(ec);
|
fc_->fail(ec);
|
||||||
|
else
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -55,20 +55,23 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init(error_code&)
|
init(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::pair<const_buffers_type, bool>>
|
boost::optional<std::pair<const_buffers_type, bool>>
|
||||||
get(error_code&)
|
get(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
return {{const_buffers_type{
|
return {{const_buffers_type{
|
||||||
body_.data(), body_.size()}, false}};
|
body_.data(), body_.size()}, false}};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finish(error_code&)
|
finish(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -107,13 +110,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init(error_code&)
|
init(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::pair<const_buffers_type, bool>>
|
boost::optional<std::pair<const_buffers_type, bool>>
|
||||||
get(error_code&)
|
get(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
body_.read = true;
|
body_.read = true;
|
||||||
return get(
|
return get(
|
||||||
std::integral_constant<bool, isSplit>{},
|
std::integral_constant<bool, isSplit>{},
|
||||||
@@ -121,8 +126,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finish(error_code&)
|
finish(error_code& ec)
|
||||||
{
|
{
|
||||||
|
ec = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user