fix: empty body shouldn't default to {}
This commit is contained in:
parent
a5cef7f269
commit
7887e0dfdb
2 changed files with 10 additions and 6 deletions
|
@ -104,8 +104,12 @@ async fn run_postwoman(args: PostWomanArgs, collection: PostWomanCollection) ->
|
||||||
println!(" |: {header}");
|
println!(" |: {header}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Ok(body) = endpoint.body() {
|
if let Some(ref _x) = endpoint.body {
|
||||||
println!(" |> {body}");
|
if let Ok(body) = endpoint.body() {
|
||||||
|
println!(" |> {body}");
|
||||||
|
} else {
|
||||||
|
println!(" |> [!] invalid body");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::{collections::HashMap, str::FromStr};
|
use std::{collections::HashMap, str::FromStr};
|
||||||
|
|
||||||
use base64::{prelude::BASE64_STANDARD, Engine};
|
use base64::{prelude::BASE64_STANDARD, Engine};
|
||||||
use http::header::{InvalidHeaderName, InvalidHeaderValue};
|
|
||||||
use http::method::InvalidMethod;
|
use http::method::InvalidMethod;
|
||||||
use http::{HeaderMap, HeaderName, HeaderValue};
|
use http::{HeaderMap, HeaderName, HeaderValue};
|
||||||
use jaq_interpret::FilterT;
|
use jaq_interpret::FilterT;
|
||||||
|
@ -33,9 +32,10 @@ pub struct EndpointConfig {
|
||||||
|
|
||||||
impl EndpointConfig {
|
impl EndpointConfig {
|
||||||
pub fn body(&mut self) -> Result<String, serde_json::Error> {
|
pub fn body(&mut self) -> Result<String, serde_json::Error> {
|
||||||
match self.body.take().unwrap_or_default() {
|
match self.body.take() {
|
||||||
StringOr::Str(x) => Ok(x.clone()),
|
None => Ok("".to_string()),
|
||||||
StringOr::T(json) => Ok(serde_json::to_string(&json)?),
|
Some(StringOr::Str(x)) => Ok(x.clone()),
|
||||||
|
Some(StringOr::T(json)) => Ok(serde_json::to_string(&json)?),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue