简体   繁体   中英

when is the handler for boost::asio::async_read_until invoked?

I'm a novice at boost.

I'm testing boost async client. the reference code is as below.

http://think-async.com/Asio/boost_asio_1_5_3/doc/html/boost_asio/example/http/client/async_client.cpp

the code is well done if "Connection: close" header value exists. but, "handle_read_status_line" handler was never invoked when I omitted "Conneciton: close" header in the HTTP request. (all handler for receiving HTTP response are invoked only when TCP connection is closed.)

In my opinion, "handle_read_status_line" should be invoked because HTTP response always include "\\\\r\\\\n" regardless of "Connection" header.

Could anybody explain to me when the handler for async_read_until is invoked?

Thanks in advance.

In general, async_read_until returns when the MatchCondition has been met.

The sample assumes that the connection is per-request. It's pretty explicit in that:

  // Start reading remaining data until EOF.
  boost::asio::async_read(socket_, response_,
      boost::asio::transfer_at_least(1),
      boost::bind(&client::handle_read_content, this,
        boost::asio::placeholders::error));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM