Boost C++ Libraries: Ticket #12131: Boost Asio async HTTP Client example source code incorrect https://svn.boost.org/trac10/ticket/12131 <p> The example source code for the async HTTP Client (<a href="http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/example/cpp03/http/client/async_client.cpp">http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/example/cpp03/http/client/async_client.cpp</a>) does not output the final read bytes inside "handle_read_content" if the parameter to the transfer_at_least(x) algorithm is greater than one. The code prematurely checks for an error code and disregards any already read data. </p> <p> The current code in question: </p> <pre class="wiki">void handle_read_content(const boost::system::error_code&amp; err) { if (!err) { // Write all of the data that has been read so far. std::cout &lt;&lt; &amp;response_; // Continue reading remaining data until EOF. boost::asio::async_read(socket_, response_, boost::asio::transfer_at_least(1), boost::bind(&amp;client::handle_read_content, this, boost::asio::placeholders::error)); } else if (err != boost::asio::error::eof) { std::cout &lt;&lt; "Error: " &lt;&lt; err &lt;&lt; "\n"; } } </pre><p> One possible "fix" for the code would be: </p> <pre class="wiki"> void handle_read_content(const boost::system::error_code&amp; err) { // Write all of the data that has been read so far. if ( response_.size() &gt; 0 ) std::cout &lt;&lt; &amp;response_; if (!err) { // Continue reading remaining data until EOF. boost::asio::async_read(socket_, response_, boost::asio::transfer_at_least(1024), boost::bind(&amp;client::handle_read_content, this, boost::asio::placeholders::error)); } else if (err != boost::asio::error::eof) { std::cout &lt;&lt; "Error: " &lt;&lt; err &lt;&lt; "\n"; } } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12131 Trac 1.4.3 anonymous Sun, 02 Oct 2016 17:03:25 GMT owner, component changed https://svn.boost.org/trac10/ticket/12131#comment:1 https://svn.boost.org/trac10/ticket/12131#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Matias Capeletto</span> to <span class="trac-author">chris_kohlhoff</span> </li> <li><strong>component</strong> <span class="trac-field-old">Documentation</span> → <span class="trac-field-new">asio</span> </li> </ul> Ticket