Skip to content

Commit

Permalink
fix: setting post body for http namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Jul 3, 2024
1 parent 9a8768e commit 6ee5b5d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/agent/namespaces/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ impl Action for Request {
let attrs = attrs.unwrap();
let method = reqwest::Method::from_str(attrs.get("method").unwrap())?;
let parsed = Self::create_url_from(&state, payload.clone()).await?;
let query_str = parsed.query().unwrap_or("").to_string();

let mut client = reqwest::Client::new().request(method.clone(), parsed.clone());
let lock = state.lock().await;
Expand All @@ -155,6 +156,13 @@ impl Action for Request {
client = client.header(key, &value.data);
}

// if there're parameters and we're not in GET, set them as the body
if !query_str.is_empty() {
if !matches!(method, reqwest::Method::GET) {
client = client.body(query_str);
}
}

log::info!(
"{}.{} {} ...",
"http".bold(),
Expand Down

0 comments on commit 6ee5b5d

Please sign in to comment.