diff --git a/CHANGELOG.md b/CHANGELOG.md index 2faf3a31..3dc188b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ Version 76: * Add serializer::get * Add serializer::chunked +API Changes: + +* Rename to serializer::keep_alive + +Actions Required: + +* Use serializer::keep_alive instead of serializer::close and + take the logical NOT of the return value. + -------------------------------------------------------------------------------- Version 75: diff --git a/include/beast/http/impl/serializer.ipp b/include/beast/http/impl/serializer.ipp index fcafe884..0e8f86c8 100644 --- a/include/beast/http/impl/serializer.ipp +++ b/include/beast/http/impl/serializer.ipp @@ -86,7 +86,7 @@ next(error_code& ec, Visit&& visit) { frdinit(std::integral_constant{}); - close_ = ! frd_->keep_alive(); + keep_alive_ = frd_->keep_alive(); chunked_ = frd_->chunked(); if(chunked_) goto go_init_c; diff --git a/include/beast/http/impl/write.ipp b/include/beast/http/impl/write.ipp index a6d9301a..6a9287c5 100644 --- a/include/beast/http/impl/write.ipp +++ b/include/beast/http/impl/write.ipp @@ -163,7 +163,7 @@ operator()( { sr_.consume(bytes_transferred); if(sr_.is_done()) - if(sr_.need_close()) + if(! sr_.keep_alive()) ec = error::end_of_stream; } h_(ec); @@ -480,11 +480,11 @@ write_some( if(f.invoked) sr.consume(f.bytes_transferred); if(sr.is_done()) - if(sr.need_close()) + if(! sr.keep_alive()) ec = error::end_of_stream; return; } - if(sr.need_close()) + if(! sr.keep_alive()) ec = error::end_of_stream; else ec.assign(0, ec.category()); diff --git a/include/beast/http/serializer.hpp b/include/beast/http/serializer.hpp index 4545ef4a..ef7b30f2 100644 --- a/include/beast/http/serializer.hpp +++ b/include/beast/http/serializer.hpp @@ -67,7 +67,7 @@ struct no_chunk_decorator if the contents of the message indicate that chunk encoding is required. If the semantics of the message indicate that the connection should be closed after the message is sent, the - function @ref need_close will return `true`. + function @ref keep_alive will return `true`. Upon construction, an optional chunk decorator may be specified. This decorator is a function object called with @@ -268,7 +268,7 @@ private: bool split_ = false; bool header_done_ = false; bool chunked_; - bool close_; + bool keep_alive_; bool more_; ChunkDecorator d_; @@ -396,21 +396,28 @@ public: return chunked_; } - /** Return `true` if Connection: close semantic is indicated. + /** Return `true` if Connection: keep-alive semantic is indicated. - Depending on the contents of the message, the end of - the body may be indicated by the end of file. In order - for the recipient (if any) to receive a complete message, - the underlying network connection must be closed when this - function returns `true`. + This function returns `true` if the semantics of the + message indicate that the connection should be kept open + after the serialized message has been transmitted. The + value depends on the HTTP version of the message, + the tokens in the Connection header, and the metadata + describing the payload body. + + Depending on the payload body, the end of the message may + be indicated by connection closuire. In order for the + recipient (if any) to receive a complete message, the + underlying stream or network connection must be closed + when this function returns `false`. This function may only be called if @ref is_header_done would return `true`. */ bool - need_close() const + keep_alive() { - return close_; + return keep_alive_; } /** Returns the next set of buffers in the serialization.