forked from boostorg/beast
Refactor accept, handshake ops
This commit is contained in:
1 parent
07535d6289
commit
70c1d361fd
4 files changed
+350
-285
No files matched your search
@@ -818,74 +818,6 @@ build_response(http::request<Body,
|
||||
return res;
|
||||
}
|
||||
|
||||
template<class NextLayer>
|
||||
template<class Decorator>
|
||||
void
|
||||
stream<NextLayer>::
|
||||
do_accept(
|
||||
Decorator const& decorator, error_code& ec)
|
||||
{
|
||||
http::request_parser<http::empty_body> p;
|
||||
http::read_header(next_layer(),
|
||||
stream_.buffer(), p, ec);
|
||||
if(ec)
|
||||
return;
|
||||
do_accept(p.get(), decorator, ec);
|
||||
}
|
||||
|
||||
template<class NextLayer>
|
||||
template<class Body, class Allocator,
|
||||
class Decorator>
|
||||
void
|
||||
stream<NextLayer>::
|
||||
do_accept(http::request<Body,
|
||||
http::basic_fields<Allocator>> const& req,
|
||||
Decorator const& decorator, error_code& ec)
|
||||
{
|
||||
auto const res = build_response(req, decorator);
|
||||
http::write(stream_, res, ec);
|
||||
if(ec)
|
||||
return;
|
||||
if(res.result() != http::status::switching_protocols)
|
||||
{
|
||||
ec = error::handshake_failed;
|
||||
// VFALCO TODO Respect keep alive setting, perform
|
||||
// teardown if Connection: close.
|
||||
return;
|
||||
}
|
||||
pmd_read(pmd_config_, req);
|
||||
open(role_type::server);
|
||||
}
|
||||
|
||||
template<class NextLayer>
|
||||
template<class RequestDecorator>
|
||||
void
|
||||
stream<NextLayer>::
|
||||
do_handshake(response_type* res_p,
|
||||
string_view host,
|
||||
string_view target,
|
||||
RequestDecorator const& decorator,
|
||||
error_code& ec)
|
||||
{
|
||||
response_type res;
|
||||
reset();
|
||||
detail::sec_ws_key_type key;
|
||||
{
|
||||
auto const req = build_request(
|
||||
key, host, target, decorator);
|
||||
pmd_read(pmd_config_, req);
|
||||
http::write(stream_, req, ec);
|
||||
}
|
||||
if(ec)
|
||||
return;
|
||||
http::read(next_layer(), stream_.buffer(), res, ec);
|
||||
if(ec)
|
||||
return;
|
||||
do_response(res, key, ec);
|
||||
if(res_p)
|
||||
*res_p = std::move(res);
|
||||
}
|
||||
|
||||
template<class NextLayer>
|
||||
void
|
||||
stream<NextLayer>::
|
||||
|
||||
Reference in new issue
Block a user