diff --git a/packages/hurl_core/src/ast/core.rs b/packages/hurl_core/src/ast/core.rs index d78222b4fe7..b7cd669f219 100644 --- a/packages/hurl_core/src/ast/core.rs +++ b/packages/hurl_core/src/ast/core.rs @@ -207,6 +207,7 @@ impl Section { SectionValue::Cookies(_) => "Cookies", SectionValue::Captures(_) => "Captures", SectionValue::MultipartFormData(_) => "MultipartFormData", + SectionValue::Options(_) => "Options", } } } @@ -221,6 +222,7 @@ pub enum SectionValue { Cookies(Vec), Captures(Vec), Asserts(Vec), + Options(Vec) } #[derive(Clone, Debug, PartialEq, Eq)] @@ -662,3 +664,33 @@ pub struct Variable { pub name: String, pub source_info: SourceInfo, } + +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum EntryOption { + Insecure { + name: OptionName, + value: OptionValue, + }, + CaCertificate { + name: OptionName, + value: OptionValue, + } +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct OptionName { + pub line_terminators: Vec, + pub space0: Whitespace, + pub name: String, + pub space1: Whitespace, +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum OptionValue { + Bool { + value: bool + }, + String { + value: String + } +} \ No newline at end of file diff --git a/packages/hurl_core/src/format/html.rs b/packages/hurl_core/src/format/html.rs index da824923e6c..80d2e9d7fe9 100644 --- a/packages/hurl_core/src/format/html.rs +++ b/packages/hurl_core/src/format/html.rs @@ -204,6 +204,11 @@ impl Htmlable for SectionValue { buffer.push_str(item.to_html().as_str()) } } + SectionValue::Options(items) => { + for item in items { + buffer.push_str(item.to_html().as_str()) + } + } } buffer } @@ -226,6 +231,12 @@ impl Htmlable for KeyValue { } } +impl Htmlable for EntryOption { + fn to_html(&self) -> String { + "TODO".to_string() + } +} + impl Htmlable for MultipartParam { fn to_html(&self) -> String { match self { diff --git a/packages/hurl_core/src/parser/error.rs b/packages/hurl_core/src/parser/error.rs index 16a44db9569..3121bffd37a 100644 --- a/packages/hurl_core/src/parser/error.rs +++ b/packages/hurl_core/src/parser/error.rs @@ -60,6 +60,7 @@ pub enum ParseError { InvalidCookieAttribute, OddNumberOfHexDigits, UrlIllegalCharacter(char), + OptionName {name: String}, } impl Error { diff --git a/packages/hurl_core/src/parser/sections.rs b/packages/hurl_core/src/parser/sections.rs index a25c09848a3..4fafc4de4a2 100644 --- a/packages/hurl_core/src/parser/sections.rs +++ b/packages/hurl_core/src/parser/sections.rs @@ -53,6 +53,7 @@ fn request_section(reader: &mut Reader) -> ParseResult<'static, Section> { "FormParams" => section_value_form_params(reader)?, "MultipartFormData" => section_value_multipart_form_data(reader)?, "Cookies" => section_value_cookies(reader)?, + "Options" => section_value_options(reader)?, _ => { return Err(Error { pos: Pos { @@ -150,6 +151,12 @@ fn section_value_asserts(reader: &mut Reader) -> ParseResult<'static, SectionVal Ok(SectionValue::Asserts(asserts)) } +fn section_value_options(reader: &mut Reader) -> ParseResult<'static, SectionValue> { + let options = zero_or_more(option, reader)?; + Ok(SectionValue::Options(options)) +} + + fn cookie(reader: &mut Reader) -> ParseResult<'static, Cookie> { // let start = reader.state.clone(); let line_terminators = optional_line_terminators(reader)?; @@ -335,6 +342,39 @@ fn assert(reader: &mut Reader) -> ParseResult<'static, Assert> { }) } +fn option(reader: &mut Reader) -> ParseResult<'static, EntryOption> { + choice( + vec![ + option_insecure, + option_cacert, + ], + reader, + ) +} + + +fn option_insecure(reader: &mut Reader) -> ParseResult<'static, EntryOption> { + let start = reader.state.clone(); + Err(Error { + pos: start.pos, + recoverable: false, + inner: ParseError::OptionName { + name: "insecure".to_string(), + }, + }) +} + +fn option_cacert(reader: &mut Reader) -> ParseResult<'static, EntryOption> { + let start = reader.state.clone(); + Err(Error { + pos: start.pos, + recoverable: false, + inner: ParseError::OptionName { + name: "cacert".to_string(), + }, + }) +} + #[cfg(test)] mod tests { use super::*;