@@ -99,7 +99,6 @@ namespace network {
99
99
boost::asio::io_service::strand strand_;
100
100
std::unique_ptr<client_connection::async_resolver> resolver_;
101
101
std::shared_ptr<client_connection::async_connection> mock_connection_;
102
- // TODO configure deadline timer for timeouts
103
102
bool timedout_;
104
103
boost::asio::deadline_timer timer_;
105
104
std::thread lifetime_thread_;
@@ -409,6 +408,16 @@ namespace network {
409
408
const boost::system::error_code &ec, std::size_t bytes_read,
410
409
std::shared_ptr<request_context> context,
411
410
std::shared_ptr<response> res) {
411
+ if (timedout_) {
412
+ set_error (boost::asio::error::timed_out, context);
413
+ return ;
414
+ }
415
+
416
+ if (ec && ec != boost::asio::error::eof) {
417
+ set_error (ec, context);
418
+ return ;
419
+ }
420
+
412
421
// update progress.
413
422
context->total_bytes_read_ += bytes_read;
414
423
if (auto progress = context->options_ .progress ()) {
@@ -425,8 +434,9 @@ namespace network {
425
434
426
435
std::istream is (&context->response_buffer_ );
427
436
string_type line;
437
+ line.reserve (bytes_read);
428
438
while (!getline_with_newline (is, line).eof ()) {
429
- res->append_body (line);
439
+ res->append_body (std::move ( line) );
430
440
}
431
441
432
442
// Keep reading the response body until we have nothing else to read.
0 commit comments