forked from boostorg/beast
WebSocket handshake response is deterministic on failure:
Add test for websocket handshake failure HTTP response fix #2364 close #2365
This commit is contained in:
4 files changed
+116
-6
No files matched your search
@@ -225,6 +225,9 @@ do_handshake(
|
||||
RequestDecorator const& decorator,
|
||||
error_code& ec)
|
||||
{
|
||||
if(res_p)
|
||||
res_p->result(http::status::internal_server_error);
|
||||
|
||||
auto& impl = *impl_;
|
||||
impl.change_status(status::handshake);
|
||||
impl.reset();
|
||||
@@ -275,12 +278,18 @@ do_handshake(
|
||||
if(impl.check_stop_now(ec))
|
||||
return;
|
||||
|
||||
impl.on_response(p.get(), key, ec);
|
||||
if(impl.check_stop_now(ec))
|
||||
return;
|
||||
|
||||
if(res_p)
|
||||
if (res_p)
|
||||
{
|
||||
// If res_p is not null, move parser's response into it.
|
||||
*res_p = p.release();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise point res_p at the response in the parser.
|
||||
res_p = &p.get();
|
||||
}
|
||||
|
||||
impl.on_response(*res_p, key, ec);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -325,6 +334,7 @@ async_handshake(
|
||||
detail::sec_ws_key_type key;
|
||||
auto req = impl_->build_request(
|
||||
key, host, target, &default_decorate_req);
|
||||
res.result(http::status::internal_server_error);
|
||||
return net::async_initiate<
|
||||
HandshakeHandler,
|
||||
void(error_code)>(
|
||||
|
||||
@@ -675,7 +675,11 @@ public:
|
||||
|
||||
@param res The HTTP Upgrade response returned by the remote
|
||||
endpoint. The caller may use the response to access any
|
||||
additional information sent by the server.
|
||||
additional information sent by the server. Note that the response object
|
||||
referenced by this parameter will be updated as long as the stream has
|
||||
received a valid HTTP response. If not (for example because of a communications
|
||||
error), the response contents will be undefined except for the result() which
|
||||
will bet set to 500, Internal Server Error.
|
||||
|
||||
@param host The name of the remote host. This is required by
|
||||
the HTTP protocol to set the "Host" header field.
|
||||
|
||||
Reference in new issue
Block a user