[英]when is the handler for boost::asio::async_read_until invoked?
我是新手。
我正在測試Boost異步客戶端。 參考代碼如下。
如果"Connection: close"
標頭值存在,則代碼編寫正確。 但是,當我在HTTP請求中省略"Conneciton: close"
標頭時,從未調用過"handle_read_status_line"
處理程序。 (僅當TCP連接關閉時,才會調用所有用於接收HTTP響應的處理程序。)
我認為,應該調用"handle_read_status_line"
因為HTTP響應始終包括"\\\\r\\\\n"
而與"Connection"
標頭無關。
有人可以向我解釋何時調用async_read_until
的處理程序嗎?
提前致謝。
通常,當滿足MatchCondition
時, async_read_until
返回。
該示例假定該連接是每個請求的。 這很明顯:
// 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));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.