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:
Vinnie Falco
2017-10-22 07:03:04 -07:00
parent 885b9dfe0b
commit d0d4e0a740
16 changed files with 122 additions and 83 deletions
+1 -14
View File
@@ -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);
+3 -10
View File
@@ -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.