Skip to content

Commit

Permalink
feat(curl): add redirection limit
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfiaschi committed Feb 27, 2024
1 parent 9adeff8 commit b39005c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/connector/curl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ pub struct Curl {
pub counter_type: Option<CounterType>,
#[serde(alias = "cache")]
pub cache_mode: Option<String>,
pub redirection_limit: usize,
}

impl fmt::Debug for Curl {
Expand All @@ -139,6 +140,7 @@ impl fmt::Debug for Curl {
.field("paginator_type", &self.paginator_type)
.field("counter_type", &self.counter_type)
.field("cache_mode", &self.cache_mode)
.field("redirection_limit", &self.redirection_limit)
.finish()
}
}
Expand All @@ -159,6 +161,7 @@ impl Default for Curl {
paginator_type: PaginatorType::default(),
counter_type: None,
cache_mode: None,
redirection_limit: 5,
}
}
}
Expand Down Expand Up @@ -210,7 +213,12 @@ impl Curl {
.try_into()
.map_err(|e| Error::new(ErrorKind::InvalidInput, e))?;

client = client.with(Logger::new());
client = client
.with(Logger::new())
.with(surf::middleware::Redirect::new(
self.redirection_limit as u8,
));

if let Some(authenticator_type) = self.authenticator_type.clone() {
client = client.with(Authenticator::new(authenticator_type));
}
Expand Down

0 comments on commit b39005c

Please sign in to comment.