mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-09-21 18:57:33 +03:00
Parser: support 'delay' options to define milliseconds request delays
This commit is contained in:
parent
7e476a44ae
commit
bcaf19f842
@ -58,6 +58,9 @@ pub fn get_entry_options(
|
||||
}
|
||||
OptionKind::Compressed(value) => runner_options.compressed = *value,
|
||||
OptionKind::ConnectTo(value) => runner_options.connects_to.push(value.clone()),
|
||||
OptionKind::Delay(value) => {
|
||||
runner_options.delay = Duration::from_millis(*value)
|
||||
}
|
||||
OptionKind::Insecure(value) => runner_options.insecure = *value,
|
||||
OptionKind::FollowLocation(value) => runner_options.follow_location = *value,
|
||||
OptionKind::MaxRedirect(value) => runner_options.max_redirect = Some(*value),
|
||||
|
@ -29,6 +29,7 @@ pub struct RunnerOptionsBuilder {
|
||||
compressed: bool,
|
||||
connect_timeout: Duration,
|
||||
connects_to: Vec<String>,
|
||||
delay: Duration,
|
||||
context_dir: ContextDir,
|
||||
continue_on_error: bool,
|
||||
cookie_input_file: Option<String>,
|
||||
@ -61,6 +62,7 @@ impl Default for RunnerOptionsBuilder {
|
||||
compressed: false,
|
||||
connect_timeout: Duration::from_secs(300),
|
||||
connects_to: vec![],
|
||||
delay: Duration::from_millis(0),
|
||||
context_dir: ContextDir::default(),
|
||||
continue_on_error: false,
|
||||
cookie_input_file: None,
|
||||
@ -140,6 +142,14 @@ impl RunnerOptionsBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets delay (timeout) before the request.
|
||||
///
|
||||
/// Default is 0 ms.
|
||||
pub fn delay(&mut self, delay: Duration) -> &mut Self {
|
||||
self.delay = delay;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets root file system to import files in Hurl.
|
||||
///
|
||||
/// This is used for both files in multipart form data and request body.
|
||||
@ -297,6 +307,7 @@ impl RunnerOptionsBuilder {
|
||||
compressed: self.compressed,
|
||||
connect_timeout: self.connect_timeout,
|
||||
connects_to: self.connects_to.clone(),
|
||||
delay: self.delay,
|
||||
context_dir: self.context_dir.clone(),
|
||||
continue_on_error: self.continue_on_error,
|
||||
cookie_input_file: self.cookie_input_file.clone(),
|
||||
@ -330,6 +341,7 @@ pub struct RunnerOptions {
|
||||
pub(crate) compressed: bool,
|
||||
pub(crate) connect_timeout: Duration,
|
||||
pub(crate) connects_to: Vec<String>,
|
||||
pub(crate) delay: Duration,
|
||||
pub(crate) context_dir: ContextDir,
|
||||
pub(crate) continue_on_error: bool,
|
||||
pub(crate) cookie_input_file: Option<String>,
|
||||
|
@ -720,6 +720,7 @@ pub enum OptionKind {
|
||||
ClientCert(Filename),
|
||||
ClientKey(Filename),
|
||||
ConnectTo(String),
|
||||
Delay(u64),
|
||||
Compressed(bool),
|
||||
Insecure(bool),
|
||||
FollowLocation(bool),
|
||||
@ -743,6 +744,7 @@ impl OptionKind {
|
||||
OptionKind::ClientKey(_) => "key",
|
||||
OptionKind::Compressed(_) => "compressed",
|
||||
OptionKind::ConnectTo(_) => "connect-to",
|
||||
OptionKind::Delay(_) => "delay",
|
||||
OptionKind::Insecure(_) => "insecure",
|
||||
OptionKind::FollowLocation(_) => "location",
|
||||
OptionKind::MaxRedirect(_) => "max-redirs",
|
||||
@ -765,6 +767,7 @@ impl OptionKind {
|
||||
OptionKind::ClientKey(filename) => filename.value.clone(),
|
||||
OptionKind::Compressed(value) => value.to_string(),
|
||||
OptionKind::ConnectTo(value) => value.clone(),
|
||||
OptionKind::Delay(value) => value.to_string(),
|
||||
OptionKind::Insecure(value) => value.to_string(),
|
||||
OptionKind::FollowLocation(value) => value.to_string(),
|
||||
OptionKind::MaxRedirect(value) => value.to_string(),
|
||||
|
@ -219,6 +219,7 @@ impl HtmlFormatter {
|
||||
OptionKind::ClientKey(filename) => self.fmt_filename(filename),
|
||||
OptionKind::Compressed(value) => self.fmt_bool(*value),
|
||||
OptionKind::ConnectTo(value) => self.fmt_string(value),
|
||||
OptionKind::Delay(value) => self.fmt_number(value),
|
||||
OptionKind::Insecure(value) => self.fmt_bool(*value),
|
||||
OptionKind::FollowLocation(value) => self.fmt_bool(*value),
|
||||
OptionKind::MaxRedirect(value) => self.fmt_number(value),
|
||||
|
@ -368,6 +368,7 @@ fn option(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
"cert" => option_cert(reader)?,
|
||||
"compressed" => option_compressed(reader)?,
|
||||
"connect-to" => option_connect_to(reader)?,
|
||||
"delay" => option_delay(reader)?,
|
||||
"key" => option_key(reader)?,
|
||||
"insecure" => option_insecure(reader)?,
|
||||
"location" => option_follow_location(reader)?,
|
||||
@ -420,6 +421,11 @@ fn option_connect_to(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
Ok(OptionKind::ConnectTo(value))
|
||||
}
|
||||
|
||||
fn option_delay(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = nonrecover(natural, reader)?;
|
||||
Ok(OptionKind::Delay(value))
|
||||
}
|
||||
|
||||
fn option_key(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = filename::parse(reader)?;
|
||||
Ok(OptionKind::ClientKey(value))
|
||||
|
Loading…
Reference in New Issue
Block a user