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}");
|
||||
}
|
||||
}
|
||||
if let Some(ref _x) = endpoint.body {
|
||||
if let Ok(body) = endpoint.body() {
|
||||
println!(" |> {body}");
|
||||
} else {
|
||||
println!(" |> [!] invalid body");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::{collections::HashMap, str::FromStr};
|
||||
|
||||
use base64::{prelude::BASE64_STANDARD, Engine};
|
||||
use http::header::{InvalidHeaderName, InvalidHeaderValue};
|
||||
use http::method::InvalidMethod;
|
||||
use http::{HeaderMap, HeaderName, HeaderValue};
|
||||
use jaq_interpret::FilterT;
|
||||
|
@ -33,9 +32,10 @@ pub struct EndpointConfig {
|
|||
|
||||
impl EndpointConfig {
|
||||
pub fn body(&mut self) -> Result<String, serde_json::Error> {
|
||||
match self.body.take().unwrap_or_default() {
|
||||
StringOr::Str(x) => Ok(x.clone()),
|
||||
StringOr::T(json) => Ok(serde_json::to_string(&json)?),
|
||||
match self.body.take() {
|
||||
None => Ok("".to_string()),
|
||||
Some(StringOr::Str(x)) => Ok(x.clone()),
|
||||
Some(StringOr::T(json)) => Ok(serde_json::to_string(&json)?),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue