mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 12:57:31 +02:00
Use synchronous writes in chunk output example
This commit is contained in:
@ -6,6 +6,7 @@ HTTP:
|
|||||||
|
|
||||||
* Add message::need_eof
|
* Add message::need_eof
|
||||||
* Use message::need_eof in example servers
|
* Use message::need_eof in example servers
|
||||||
|
* Use synchronous writes in chunk output example
|
||||||
|
|
||||||
API Changes:
|
API Changes:
|
||||||
|
|
||||||
|
@ -180,34 +180,18 @@ void fxx() {
|
|||||||
// Write the next chunk with the chunk extensions
|
// Write the next chunk with the chunk extensions
|
||||||
// The implementation will make a copy of the extensions object,
|
// The implementation will make a copy of the extensions object,
|
||||||
// so the caller does not need to manage lifetime issues.
|
// so the caller does not need to manage lifetime issues.
|
||||||
boost::asio::async_write(sock, make_chunk(get_next_chunk_body(), ext),
|
boost::asio::write(sock, make_chunk(get_next_chunk_body(), ext));
|
||||||
[](error_code ec, std::size_t)
|
|
||||||
{
|
|
||||||
if(ec)
|
|
||||||
std::cout << "Error: " << ec.message() << std::endl;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Write the next chunk with the chunk extensions
|
// Write the next chunk with the chunk extensions
|
||||||
// The implementation will make a copy of the extensions object, storing the copy
|
// 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.
|
// using the custom allocator, so the caller does not need to manage lifetime issues.
|
||||||
boost::asio::async_write(sock,
|
boost::asio::write(sock, make_chunk(get_next_chunk_body(), ext, std::allocator<char>{}));
|
||||||
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;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Write the next chunk with the chunk extensions
|
// Write the next chunk with the chunk extensions
|
||||||
// The implementation allocates memory using the default allocator and takes ownership
|
// 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.
|
// of the extensions object, so the caller does not need to manage lifetime issues.
|
||||||
// Note: ext is moved
|
// Note: ext is moved
|
||||||
boost::asio::async_write(sock, make_chunk(get_next_chunk_body(), std::move(ext)),
|
boost::asio::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;
|
|
||||||
});
|
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user