Export [Options] to JSON

This commit is contained in:
Fabrice Reix 2023-06-24 12:11:46 +02:00 committed by hurl-bot
parent 0e1705b4f0
commit fd8cac04d6
No known key found for this signature in database
GPG Key ID: 1283A2B4A0DCAF8D
16 changed files with 127 additions and 13 deletions

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/redirect/7"},"response":{"status":200}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/redirect/7","options":[{"name":"location","value":true},{"name":"max-redirs","value":5}]},"response":{"status":200}}]}

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/not-found"},"response":{"status":200}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/not-found","options":[{"name":"retry","value":2},{"name":"retry-interval","value":0}]},"response":{"status":200}}]}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/follow-redirect"},"response":{"status":302,"asserts":[{"query":{"type":"header","name":"Location"},"predicate":{"type":"equal","value":"http://localhost:8000/following-redirect"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/follow-redirect"},"response":{"status":302,"asserts":[{"query":{"type":"header","name":"Location"},"predicate":{"type":"equal","value":"http://localhost:8000/following-redirect"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/follow-redirect"},"response":{"status":200,"asserts":[{"query":{"type":"header","name":"Location"},"predicate":{"not":true,"type":"exist"}}],"body":{"type":"text","value":"Followed redirect!"}}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/follow-redirect"},"response":{"status":302,"asserts":[{"query":{"type":"header","name":"Location"},"predicate":{"type":"equal","value":"http://localhost:8000/following-redirect"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/follow-redirect","options":[{"name":"location","value":false}]},"response":{"status":302,"asserts":[{"query":{"type":"header","name":"Location"},"predicate":{"type":"equal","value":"http://localhost:8000/following-redirect"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/follow-redirect","options":[{"name":"location","value":true}]},"response":{"status":200,"asserts":[{"query":{"type":"header","name":"Location"},"predicate":{"not":true,"type":"exist"}}],"body":{"type":"text","value":"Followed redirect!"}}}]}

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.allFilms.films"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":6}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].title"},"predicate":{"type":"equal","value":"A New Hope"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].director"},"predicate":{"type":"equal","value":"George Lucas"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].releaseDate"},"predicate":{"type":"equal","value":"1977-05-25"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].openingCrawl"},"predicate":{"not":true,"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[1].title"},"predicate":{"type":"equal","value":"The Empire Strikes Back"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[2].title"},"predicate":{"type":"equal","value":"Return of the Jedi"}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","headers":[{"name":"Content-Type","value":"application/json"}],"body":{"type":"json","value":{"query":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}"}}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.allFilms.films"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":6}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"query Query {\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.allFilms.films"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":6}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}\n\nvariables {\n \"id\": \"cGVvcGxlOjQ=\"\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.person.name"},"predicate":{"type":"equal","value":"Darth Vader"}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}\n\nvariables {\n \"id\": \"{{id}}\"\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.person.name"},"predicate":{"type":"equal","value":"Darth Vader"}}]}}]}
{"entries":[{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.allFilms.films"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":6}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].title"},"predicate":{"type":"equal","value":"A New Hope"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].director"},"predicate":{"type":"equal","value":"George Lucas"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].releaseDate"},"predicate":{"type":"equal","value":"1977-05-25"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].openingCrawl"},"predicate":{"not":true,"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[1].title"},"predicate":{"type":"equal","value":"The Empire Strikes Back"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[2].title"},"predicate":{"type":"equal","value":"Return of the Jedi"}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","headers":[{"name":"Content-Type","value":"application/json"}],"body":{"type":"json","value":{"query":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}"}}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.allFilms.films"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":6}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"query Query {\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.allFilms.films"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":6}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}\n\nvariables {\n \"id\": \"cGVvcGxlOjQ=\"\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.person.name"},"predicate":{"type":"equal","value":"Darth Vader"}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","options":[{"name":"variable","value":"id=cGVvcGxlOjQ="}],"body":{"type":"graphql","value":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}\n\nvariables {\n \"id\": \"{{id}}\"\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.person.name"},"predicate":{"type":"equal","value":"Darth Vader"}}]}}]}

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello"},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello","options":[{"name":"insecure","value":false}]},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}}]}

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello"},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}},{"request":{"method":"GET","url":"http://localhost:8000/cookies/set-session-cookie2-valueA"},"response":{"status":200,"asserts":[{"query":{"type":"cookie","expr":"cookie2"},"predicate":{"type":"equal","value":"valueA"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/follow-redirect"},"response":{"status":302,"asserts":[{"query":{"type":"header","name":"Location"},"predicate":{"type":"equal","value":"http://localhost:8000/following-redirect"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/follow-redirect"},"response":{"status":200,"asserts":[{"query":{"type":"header","name":"Location"},"predicate":{"not":true,"type":"exist"}}],"body":{"type":"text","value":"Followed redirect!"}}},{"request":{"method":"GET","url":"http://localhost:8000/captures"},"response":{"status":200,"captures":[{"name":"param1","query":{"type":"header","name":"header1"}},{"name":"param2","query":{"type":"header","name":"header2"},"filters":[{"type":"regex","expr":"Hello (.*)!"}]},{"name":"param3","query":{"type":"header","name":"header2"},"filters":[{"type":"regex","expr":{"type":"regex","value":"Hello (.*)!"}}]},{"name":"data1","query":{"type":"body"}},{"name":"data2","query":{"type":"variable","name":"data1"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/assert-json"},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.errors[1].id"},"predicate":{"type":"equal","value":"error2"}},{"query":{"type":"jsonpath","expr":"$.tags"},"predicate":{"type":"include","value":"test"}},{"query":{"type":"jsonpath","expr":"$.tags"},"predicate":{"not":true,"type":"include","value":"prod"}},{"query":{"type":"jsonpath","expr":"$.tags"},"predicate":{"not":true,"type":"include","value":null}}]}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello"},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}},{"request":{"method":"GET","url":"http://localhost:8000/cookies/set-session-cookie2-valueA"},"response":{"status":200,"asserts":[{"query":{"type":"cookie","expr":"cookie2"},"predicate":{"type":"equal","value":"valueA"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/follow-redirect"},"response":{"status":302,"asserts":[{"query":{"type":"header","name":"Location"},"predicate":{"type":"equal","value":"http://localhost:8000/following-redirect"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/follow-redirect","options":[{"name":"location","value":true}]},"response":{"status":200,"asserts":[{"query":{"type":"header","name":"Location"},"predicate":{"not":true,"type":"exist"}}],"body":{"type":"text","value":"Followed redirect!"}}},{"request":{"method":"GET","url":"http://localhost:8000/captures"},"response":{"status":200,"captures":[{"name":"param1","query":{"type":"header","name":"header1"}},{"name":"param2","query":{"type":"header","name":"header2"},"filters":[{"type":"regex","expr":"Hello (.*)!"}]},{"name":"param3","query":{"type":"header","name":"header2"},"filters":[{"type":"regex","expr":{"type":"regex","value":"Hello (.*)!"}}]},{"name":"data1","query":{"type":"body"}},{"name":"data2","query":{"type":"variable","name":"data1"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/assert-json"},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.errors[1].id"},"predicate":{"type":"equal","value":"error2"}},{"query":{"type":"jsonpath","expr":"$.tags"},"predicate":{"type":"include","value":"test"}},{"query":{"type":"jsonpath","expr":"$.tags"},"predicate":{"not":true,"type":"include","value":"prod"}},{"query":{"type":"jsonpath","expr":"$.tags"},"predicate":{"not":true,"type":"include","value":null}}]}}]}

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/any/../hello"},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}},{"request":{"method":"GET","url":"http://localhost:8000/path-as-is/../resource"},"response":{"status":200}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/any/../hello"},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}},{"request":{"method":"GET","url":"http://localhost:8000/path-as-is/../resource","options":[{"name":"path-as-is","value":true}]},"response":{"status":200}}]}

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/redirected"},"response":{"status":200,"asserts":[{"query":{"type":"url"},"predicate":{"type":"equal","value":"http://localhost:8000/redirected"}}],"body":{"type":"text","value":"Redirected"}}},{"request":{"method":"GET","url":"http://localhost:8000/redirect-absolute"},"response":{"status":302,"headers":[{"name":"Location","value":"http://localhost:8000/redirected"}],"asserts":[{"query":{"type":"url"},"predicate":{"type":"equal","value":"http://localhost:8000/redirect-absolute"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/redirect-absolute"},"response":{"status":200,"asserts":[{"query":{"type":"url"},"predicate":{"type":"equal","value":"http://localhost:8000/redirected"}}],"body":{"type":"text","value":"Redirected"}}},{"request":{"method":"GET","url":"http://localhost:8000/redirect-relative"},"response":{"status":302,"headers":[{"name":"Location","value":"/redirected"}],"asserts":[{"query":{"type":"url"},"predicate":{"type":"equal","value":"http://localhost:8000/redirect-relative"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/redirect-relative"},"response":{"status":200,"asserts":[{"query":{"type":"url"},"predicate":{"type":"equal","value":"http://localhost:8000/redirected"}}],"body":{"type":"text","value":"Redirected"}}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/redirected"},"response":{"status":200,"asserts":[{"query":{"type":"url"},"predicate":{"type":"equal","value":"http://localhost:8000/redirected"}}],"body":{"type":"text","value":"Redirected"}}},{"request":{"method":"GET","url":"http://localhost:8000/redirect-absolute"},"response":{"status":302,"headers":[{"name":"Location","value":"http://localhost:8000/redirected"}],"asserts":[{"query":{"type":"url"},"predicate":{"type":"equal","value":"http://localhost:8000/redirect-absolute"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/redirect-absolute","options":[{"name":"location","value":true}]},"response":{"status":200,"asserts":[{"query":{"type":"url"},"predicate":{"type":"equal","value":"http://localhost:8000/redirected"}}],"body":{"type":"text","value":"Redirected"}}},{"request":{"method":"GET","url":"http://localhost:8000/redirect-relative"},"response":{"status":302,"headers":[{"name":"Location","value":"/redirected"}],"asserts":[{"query":{"type":"url"},"predicate":{"type":"equal","value":"http://localhost:8000/redirect-relative"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/redirect-relative","options":[{"name":"location","value":true}]},"response":{"status":200,"asserts":[{"query":{"type":"url"},"predicate":{"type":"equal","value":"http://localhost:8000/redirected"}}],"body":{"type":"text","value":"Redirected"}}}]}

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"POST","url":"http://localhost:8000/jobs"},"response":{"status":201,"captures":[{"name":"job_id","query":{"type":"jsonpath","expr":"$.id"}}],"asserts":[{"query":{"type":"jsonpath","expr":"$.state"},"predicate":{"type":"equal","value":"RUNNING"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/jobs/{{job_id}}"},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.state"},"predicate":{"type":"equal","value":"COMPLETED"}}]}},{"request":{"method":"DELETE","url":"http://localhost:8000/jobs/{{job_id}}"},"response":{"status":200}},{"request":{"method":"GET","url":"http://localhost:8000/jobs/{{job_id}}"},"response":{"status":404}}]}
{"entries":[{"request":{"method":"POST","url":"http://localhost:8000/jobs"},"response":{"status":201,"captures":[{"name":"job_id","query":{"type":"jsonpath","expr":"$.id"}}],"asserts":[{"query":{"type":"jsonpath","expr":"$.state"},"predicate":{"type":"equal","value":"RUNNING"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/jobs/{{job_id}}","options":[{"name":"retry","value":10},{"name":"retry-interval","value":100}]},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.state"},"predicate":{"type":"equal","value":"COMPLETED"}}]}},{"request":{"method":"DELETE","url":"http://localhost:8000/jobs/{{job_id}}"},"response":{"status":200}},{"request":{"method":"GET","url":"http://localhost:8000/jobs/{{job_id}}"},"response":{"status":404}}]}

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"POST","url":"http://localhost:8000/variables","headers":[{"name":"Name","value":"{{name}}"},{"name":"Age","value":"{{age}}"},{"name":"Height","value":"{{height}}"},{"name":"Female","value":"{{female}}"},{"name":"Id","value":"{{my-id}}"},{"name":"A-Null","value":"{{a_null}}"},{"name":"Country","value":"{{country}}"},{"name":"Planet","value":"{{planet}}"},{"name":"Galaxy","value":"{{galaxy}}"}],"body":{"type":"json","value":{"name":"{{name}}","age":"{{age}}","height":"{{height}}","female":"{{female}}","id":"{{my-id}}","a_null":"{{a_null}}","country":"{{country}}","planet":"{{planet}}","galaxy":"{{galaxy}}"}}},"response":{"status":200,"asserts":[{"query":{"type":"variable","name":"name"},"predicate":{"type":"equal","value":"Jennifer"}},{"query":{"type":"variable","name":"female"},"predicate":{"type":"equal","value":true}},{"query":{"type":"variable","name":"age"},"predicate":{"type":"equal","value":30}},{"query":{"type":"variable","name":"height"},"predicate":{"type":"equal","value":1.70}},{"query":{"type":"variable","name":"a_null"},"predicate":{"type":"equal","value":null}},{"query":{"type":"variable","name":"my-id"},"predicate":{"type":"equal","value":"123"}},{"query":{"type":"variable","name":"country"},"predicate":{"type":"equal","value":"Italy"}},{"query":{"type":"variable","name":"planet"},"predicate":{"type":"equal","value":"The Earth"}},{"query":{"type":"variable","name":"galaxy"},"predicate":{"type":"equal","value":"Milky Way"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/variable/country"},"response":{"status":200,"body":{"type":"text","value":"{{country}}"}}},{"request":{"method":"GET","url":"http://localhost:8000/variable/planet"},"response":{"status":200,"body":{"type":"text","value":"{{planet}}"}}}]}
{"entries":[{"request":{"method":"POST","url":"http://localhost:8000/variables","headers":[{"name":"Name","value":"{{name}}"},{"name":"Age","value":"{{age}}"},{"name":"Height","value":"{{height}}"},{"name":"Female","value":"{{female}}"},{"name":"Id","value":"{{my-id}}"},{"name":"A-Null","value":"{{a_null}}"},{"name":"Country","value":"{{country}}"},{"name":"Planet","value":"{{planet}}"},{"name":"Galaxy","value":"{{galaxy}}"}],"options":[{"name":"variable","value":"country=Italy"},{"name":"variable","value":"planet=The Earth"}],"body":{"type":"json","value":{"name":"{{name}}","age":"{{age}}","height":"{{height}}","female":"{{female}}","id":"{{my-id}}","a_null":"{{a_null}}","country":"{{country}}","planet":"{{planet}}","galaxy":"{{galaxy}}"}}},"response":{"status":200,"asserts":[{"query":{"type":"variable","name":"name"},"predicate":{"type":"equal","value":"Jennifer"}},{"query":{"type":"variable","name":"female"},"predicate":{"type":"equal","value":true}},{"query":{"type":"variable","name":"age"},"predicate":{"type":"equal","value":30}},{"query":{"type":"variable","name":"height"},"predicate":{"type":"equal","value":1.70}},{"query":{"type":"variable","name":"a_null"},"predicate":{"type":"equal","value":null}},{"query":{"type":"variable","name":"my-id"},"predicate":{"type":"equal","value":"123"}},{"query":{"type":"variable","name":"country"},"predicate":{"type":"equal","value":"Italy"}},{"query":{"type":"variable","name":"planet"},"predicate":{"type":"equal","value":"The Earth"}},{"query":{"type":"variable","name":"galaxy"},"predicate":{"type":"equal","value":"Milky Way"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/variable/country"},"response":{"status":200,"body":{"type":"text","value":"{{country}}"}}},{"request":{"method":"GET","url":"http://localhost:8000/variable/planet"},"response":{"status":200,"body":{"type":"text","value":"{{planet}}"}}}]}

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello"}},{"request":{"method":"GET","url":"http://localhost:8000/hello"},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}},{"request":{"method":"GET","url":"http://localhost:8000/hello"}},{"request":{"method":"GET","url":"http://localhost:8000/hello"}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello"}},{"request":{"method":"GET","url":"http://localhost:8000/hello","options":[{"name":"verbose","value":true}]},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}},{"request":{"method":"GET","url":"http://localhost:8000/hello"}},{"request":{"method":"GET","url":"http://localhost:8000/hello","options":[{"name":"very-verbose","value":true}]}}]}

View File

@ -89,6 +89,15 @@ impl Request {
}
None
}
pub fn options(&self) -> Vec<EntryOption> {
for section in &self.sections {
if let SectionValue::Options(options) = &section.value {
return options.clone();
}
}
vec![]
}
}
#[derive(Clone, Debug, PartialEq, Eq)]

View File

@ -158,6 +158,25 @@ impl fmt::Display for MultilineString {
}
}
impl fmt::Display for VariableDefinition {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}={}", self.name, self.value)
}
}
impl fmt::Display for VariableValue {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
VariableValue::Null { .. } => "null".to_string(),
VariableValue::Bool(value) => value.to_string(),
VariableValue::Integer(n) => n.to_string(),
VariableValue::Float(x) => x.to_string(),
VariableValue::String(s) => s.to_string(),
};
write!(f, "{}", s)
}
}
impl PredicateFuncValue {
pub fn name(&self) -> String {
match self {

View File

@ -83,6 +83,10 @@ impl ToJson for Request {
let cookies = self.cookies().iter().map(|c| c.to_json()).collect();
attributes.push(("cookies".to_string(), JValue::List(cookies)));
}
if !self.options().is_empty() {
let options = self.options().iter().map(|c| c.to_json()).collect();
attributes.push(("options".to_string(), JValue::List(options)));
}
if let Some(body) = &self.body {
attributes.push(("body".to_string(), body.to_json()));
}
@ -265,6 +269,88 @@ impl ToJson for Cookie {
}
}
impl ToJson for EntryOption {
fn to_json(&self) -> JValue {
let attributes = match self {
EntryOption::CaCertificate(value) => vec![
("name".to_string(), JValue::String("cacert".to_string())),
(
"value".to_string(),
JValue::String(value.filename.value.clone()),
),
],
EntryOption::ClientCert(value) => vec![
("name".to_string(), JValue::String("cert".to_string())),
(
"value".to_string(),
JValue::String(value.filename.value.clone()),
),
],
EntryOption::ClientKey(value) => vec![
("name".to_string(), JValue::String("key".to_string())),
(
"value".to_string(),
JValue::String(value.filename.value.clone()),
),
],
EntryOption::Compressed(value) => vec![
("name".to_string(), JValue::String("compressed".to_string())),
("value".to_string(), JValue::Boolean(value.value)),
],
EntryOption::Insecure(value) => vec![
("name".to_string(), JValue::String("insecure".to_string())),
("value".to_string(), JValue::Boolean(value.value)),
],
EntryOption::FollowLocation(value) => vec![
("name".to_string(), JValue::String("location".to_string())),
("value".to_string(), JValue::Boolean(value.value)),
],
EntryOption::MaxRedirect(value) => vec![
("name".to_string(), JValue::String("max-redirs".to_string())),
("value".to_string(), JValue::Number(value.value.to_string())),
],
EntryOption::PathAsIs(value) => vec![
("name".to_string(), JValue::String("path-as-is".to_string())),
("value".to_string(), JValue::Boolean(value.value)),
],
EntryOption::Proxy(value) => vec![
("name".to_string(), JValue::String("proxy".to_string())),
("value".to_string(), JValue::String(value.value.clone())),
],
EntryOption::Retry(value) => vec![
("name".to_string(), JValue::String("retry".to_string())),
("value".to_string(), JValue::Number(value.value.to_string())),
],
EntryOption::RetryInterval(value) => vec![
(
"name".to_string(),
JValue::String("retry-interval".to_string()),
),
("value".to_string(), JValue::Number(value.value.to_string())),
],
EntryOption::Variable(value) => vec![
("name".to_string(), JValue::String("variable".to_string())),
(
"value".to_string(),
JValue::String(format!("{}={}", value.value.name, value.value.value)),
),
],
EntryOption::Verbose(value) => vec![
("name".to_string(), JValue::String("verbose".to_string())),
("value".to_string(), JValue::Boolean(value.value)),
],
EntryOption::VeryVerbose(value) => vec![
(
"name".to_string(),
JValue::String("very-verbose".to_string()),
),
("value".to_string(), JValue::Boolean(value.value)),
],
};
JValue::Object(attributes)
}
}
impl ToJson for Capture {
fn to_json(&self) -> JValue {
let mut attributes = vec![