cpp-netlib/cpp-netlib — pull request #348 by daedric (2013-12-13 16:10:58+00:00)
Title: Allow to read a new request on the async_connection

Here is an example how to use the member function:
void sendResponse(Request& request,
int http_code,
const std::string& body)
{
setHeader("Content-Length", std::to_string(body.size()));
auto code = static_cast(http_code);
request.connection->set_status(code);
request.connection->set_headers(boost::make_iterator_range(headers_));
request.connection->write(body, [&request](const boost::system::error_code& err){
if (err) {
BOOST_LOG_TRIVIAL(error) << "Error during IO: " << err.message();
}

request.connection->restart();
});
}

The member function will only reset the current state of the connection as if
nothing was performed before.

This code is missing the checks to see if the client actually want to close its
connection or if the http version is consistent.
There is not any timeout check either: no checks were performed before and it
is unlikely that the async_server or even the sync_server will directly serve
request from the Internet.