Use synchronous writes in chunk output example

This commit is contained in:
Vinnie Falco
2017-10-25 22:55:56 -07:00
parent 2555942010
commit 3d3bc87042
2 changed files with 4 additions and 19 deletions

View File

@ -6,6 +6,7 @@ HTTP:
* Add message::need_eof
* Use message::need_eof in example servers
* Use synchronous writes in chunk output example
API Changes:

View File

@ -180,34 +180,18 @@ void fxx() {
// Write the next chunk with the chunk extensions
// The implementation will make a copy of the extensions object,
// so the caller does not need to manage lifetime issues.
boost::asio::async_write(sock, make_chunk(get_next_chunk_body(), ext),
[](error_code ec, std::size_t)
{
if(ec)
std::cout << "Error: " << ec.message() << std::endl;
});
boost::asio::write(sock, make_chunk(get_next_chunk_body(), ext));
// Write the next chunk with the chunk extensions
// The implementation will make a copy of the extensions object, storing the copy
// using the custom allocator, so the caller does not need to manage lifetime issues.
boost::asio::async_write(sock,
make_chunk(get_next_chunk_body(), ext, std::allocator<char>{}),
[](error_code ec, std::size_t)
{
if(ec)
std::cout << "Error: " << ec.message() << std::endl;
});
boost::asio::write(sock, make_chunk(get_next_chunk_body(), ext, std::allocator<char>{}));
// Write the next chunk with the chunk extensions
// The implementation allocates memory using the default allocator and takes ownership
// of the extensions object, so the caller does not need to manage lifetime issues.
// Note: ext is moved
boost::asio::async_write(sock, make_chunk(get_next_chunk_body(), std::move(ext)),
[](error_code ec, std::size_t)
{
if(ec)
std::cout << "Error: " << ec.message() << std::endl;
});
boost::asio::write(sock, make_chunk(get_next_chunk_body(), std::move(ext)));
//]
}