forked from boostorg/beast
Better treatment of SSL short reads:
fix #38 This improves the behavior when encountering a short read: * Any stream error encountered during a read is converting into `http::error::partial_message` if some data was received but the message is incomplete. * Examples squelch SSL short read errors from the logs.
This commit is contained in:
@@ -43,7 +43,7 @@ parse_until(
|
||||
{
|
||||
if(parser.got_some())
|
||||
{
|
||||
// caller sees EOF on next read
|
||||
// Caller sees EOF on next read
|
||||
ec = {};
|
||||
parser.put_eof(ec);
|
||||
BOOST_ASSERT(ec || parser.is_done());
|
||||
@@ -55,7 +55,17 @@ parse_until(
|
||||
return 0;
|
||||
}
|
||||
if(ec)
|
||||
{
|
||||
// Upgrade the error if we have a partial message.
|
||||
// This causes SSL short reads (and every other error)
|
||||
// to be converted into something else, allowing the
|
||||
// caller to distinguish an SSL short read which
|
||||
// represents a safe connection closure, versus
|
||||
// a closure with data loss.
|
||||
if(parser.got_some() && ! parser.is_done())
|
||||
ec = error::partial_message;
|
||||
return 0;
|
||||
}
|
||||
if(parser.is_done())
|
||||
return 0;
|
||||
if(buffer.size() > 0)
|
||||
|
||||
@@ -105,6 +105,7 @@ public:
|
||||
// What else could it be?
|
||||
BOOST_ASSERT(sr_.is_done());
|
||||
}
|
||||
|
||||
return net::post(
|
||||
s_.get_executor(),
|
||||
beast::bind_front_handler(
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace websocket {
|
||||
|
||||
/*
|
||||
|
||||
See
|
||||
http://stackoverflow.com/questions/32046034/what-is-the-proper-way-to-securely-disconnect-an-asio-ssl-socket/32054476#32054476
|
||||
See
|
||||
http://stackoverflow.com/questions/32046034/what-is-the-proper-way-to-securely-disconnect-an-asio-ssl-socket/32054476#32054476
|
||||
|
||||
Behavior of ssl::stream regarding close_
|
||||
Behavior of ssl::stream regarding close_notify
|
||||
|
||||
If the remote host calls async_shutdown then the
|
||||
local host's async_read will complete with eof.
|
||||
|
||||
Reference in New Issue
Block a user