0
votes

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.

1

1 Answers

0
votes

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));