@@ -625,23 +625,24 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
625
625
struct timer_guard {
626
626
timer_guard (coro_http_client *self,
627
627
std::chrono::steady_clock::duration duration, std::string msg)
628
- : self(self) {
628
+ : self(self), dur_(duration) {
629
629
self->socket_ ->is_timeout_ = false ;
630
630
631
- if (self-> enable_timeout_ && duration.count () >= 0 ) {
631
+ if (duration.count () >= 0 ) {
632
632
self->timeout (self->timer_ , duration, std::move (msg))
633
633
.start ([](auto &&) {
634
634
});
635
635
}
636
636
return ;
637
637
}
638
638
~timer_guard () {
639
- if (self-> enable_timeout_ && self->socket_ ->is_timeout_ == false ) {
639
+ if (dur_. count () > 0 && self->socket_ ->is_timeout_ == false ) {
640
640
std::error_code ignore_ec;
641
641
self->timer_ .cancel (ignore_ec);
642
642
}
643
643
}
644
644
coro_http_client *self;
645
+ std::chrono::steady_clock::duration dur_;
645
646
};
646
647
647
648
async_simple::coro::Lazy<resp_data> async_download (std::string uri,
@@ -1457,12 +1458,10 @@ class coro_http_client : public std::enable_shared_from_this<coro_http_client> {
1457
1458
}
1458
1459
1459
1460
void set_conn_timeout (std::chrono::steady_clock::duration timeout_duration) {
1460
- enable_timeout_ = true ;
1461
1461
conn_timeout_duration_ = timeout_duration;
1462
1462
}
1463
1463
1464
1464
void set_req_timeout (std::chrono::steady_clock::duration timeout_duration) {
1465
- enable_timeout_ = true ;
1466
1465
req_timeout_duration_ = timeout_duration;
1467
1466
}
1468
1467
0 commit comments