Provide websocket::stream accept() overloads (API Change):

This adds enough functions to the accept and async_accept
overload set to cover all combinations of request, buffers,
and error_code parameters. This also fixes a defect where
providing a complete Upgrade request when there are additional
unprocessed octets remaining in the callers stream buffer
could not be furnished to the WebSocket implementation.
This commit is contained in:
Vinnie Falco committed 2017-05-05 10:01:17 -07:00
1 parent a715825dc4
commit 235fe68acb
8 files changed
+1248 -559

No files matched your search

+37
View File
@@ -82,6 +82,43 @@ reset()
stream_.buffer().size());
}
template<class NextLayer>
void
stream<NextLayer>::
do_accept(error_code& ec)
{
http::header_parser<true, http::fields> p;
auto const bytes_used = http::read_some(
next_layer(), stream_.buffer(), p, ec);
if(ec)
return;
BOOST_ASSERT(p.got_header());
stream_.buffer().consume(bytes_used);
do_accept(p.get(), ec);
}
template<class NextLayer>
template<class Fields>
void
stream<NextLayer>::
do_accept(http::header<true, Fields> const& req,
error_code& ec)
{
auto const res = build_response(req);
http::write(stream_, res, ec);
if(ec)
return;
if(res.status != 101)
{
ec = error::handshake_failed;
// VFALCO TODO Respect keep alive setting, perform
// teardown if Connection: close.
return;
}
pmd_read(pmd_config_, req.fields);
open(detail::role_type::server);
}
template<class NextLayer>
http::request_header
stream<NextLayer>::