forked from boostorg/beast
http write returns success on connection close (API Change):
fix #767 The write family of HTTP stream algorithms no longer returns error::end_of_stream when the message indicates that the connection should be closed. Actions Required: * Add code to servers to close the connection after successfully writing a message where `message::keep_alive()` would return `false`.
This commit is contained in:
@@ -162,12 +162,7 @@ operator()(
|
||||
error_code ec, std::size_t bytes_transferred)
|
||||
{
|
||||
if(! ec)
|
||||
{
|
||||
sr_.consume(bytes_transferred);
|
||||
if(sr_.is_done())
|
||||
if(! sr_.keep_alive())
|
||||
ec = error::end_of_stream;
|
||||
}
|
||||
h_(ec, bytes_transferred);
|
||||
}
|
||||
|
||||
@@ -478,15 +473,9 @@ write_some(
|
||||
return f.bytes_transferred;
|
||||
if(f.invoked)
|
||||
sr.consume(f.bytes_transferred);
|
||||
if(sr.is_done())
|
||||
if(! sr.keep_alive())
|
||||
ec = error::end_of_stream;
|
||||
return f.bytes_transferred;
|
||||
}
|
||||
if(! sr.keep_alive())
|
||||
ec = error::end_of_stream;
|
||||
else
|
||||
ec.assign(0, ec.category());
|
||||
ec.assign(0, ec.category());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -909,8 +898,6 @@ operator<<(std::ostream& os,
|
||||
sr.next(ec, f);
|
||||
if(os.fail())
|
||||
break;
|
||||
if(ec == error::end_of_stream)
|
||||
ec.assign(0, ec.category());
|
||||
if(ec)
|
||||
{
|
||||
os.setstate(std::ios::failbit);
|
||||
|
||||
@@ -440,9 +440,7 @@ async_write(
|
||||
|
||||
This operation is implemented in terms of one or more calls to the stream's
|
||||
`write_some` function. The algorithm will use a temporary @ref serializer
|
||||
with an empty chunk decorator to produce buffers. If the semantics of the
|
||||
message indicate that the connection should be closed after the message is
|
||||
sent, the error delivered by this function will be @ref error::end_of_stream
|
||||
with an empty chunk decorator to produce buffers.
|
||||
|
||||
@param stream The stream to which the data is to be written.
|
||||
The type must support the @b SyncWriteStream concept.
|
||||
@@ -474,9 +472,7 @@ write(
|
||||
|
||||
This operation is implemented in terms of one or more calls to the stream's
|
||||
`write_some` function. The algorithm will use a temporary @ref serializer
|
||||
with an empty chunk decorator to produce buffers. If the semantics of the
|
||||
message indicate that the connection should be closed after the message is
|
||||
sent, the error delivered by this function will be @ref error::end_of_stream
|
||||
with an empty chunk decorator to produce buffers.
|
||||
|
||||
@param stream The stream to which the data is to be written.
|
||||
The type must support the @b SyncWriteStream concept.
|
||||
@@ -512,10 +508,7 @@ write(
|
||||
`async_write_some` function, and is known as a <em>composed operation</em>.
|
||||
The program must ensure that the stream performs no other write operations
|
||||
until this operation completes. The algorithm will use a temporary
|
||||
@ref serializer with an empty chunk decorator to produce buffers. If
|
||||
the semantics of the message indicate that the connection should be
|
||||
closed after the message is sent, the error delivered by this function
|
||||
will be @ref error::end_of_stream
|
||||
@ref serializer with an empty chunk decorator to produce buffers.
|
||||
|
||||
@param stream The stream to which the data is to be written.
|
||||
The type must support the @b AsyncWriteStream concept.
|
||||
|
||||
Reference in New Issue
Block a user