Skip to content

Commit

Permalink
Fix client-timeout not applied
Browse files Browse the repository at this point in the history
  • Loading branch information
lifegpc authored Sep 24, 2024
1 parent 418bf58 commit 9cc031e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/webclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ impl WebClient {
self.retry_interval.get_ref()
}

pub fn get_timeout<'a>(&'a self) -> RwLockReadGuard<'a, Option<Duration>> {
self.timeout.get_ref()
}

/// Used to handle Set-Cookie header in an [Response]
/// * `r` - reference to an [Response]
pub fn handle_set_cookie(&self, r: &Response) {
Expand Down Expand Up @@ -398,6 +402,12 @@ impl WebClient {
if c.len() > 0 {
r = r.header("Cookie", c.as_str());
}
match self.get_timeout().as_ref() {
Some(t) => {
r = r.timeout(t.clone());
}
None => {}
}
self.handle_req_middlewares(r.build()?)
}

Expand Down Expand Up @@ -528,6 +538,12 @@ impl WebClient {
}
None => {}
}
match self.get_timeout().as_ref() {
Some(t) => {
r = r.timeout(t.clone());
}
None => {}
}
self.handle_req_middlewares(r.build()?)
}

Expand Down Expand Up @@ -573,6 +589,12 @@ impl WebClient {
r = r.header("Cookie", c.as_str());
}
r = r.multipart(form);
match self.get_timeout().as_ref() {
Some(t) => {
r = r.timeout(t.clone());
}
None => {}
}
self.handle_req_middlewares(r.build()?)
}
}
Expand Down

0 comments on commit 9cc031e

Please sign in to comment.