Skip to content

Commit

Permalink
updated to work with recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ayax79 committed Sep 4, 2024
1 parent 4792328 commit 9f7a8cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion crates/nu-command/src/network/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,14 @@ fn send_json_request(
signals: &Signals,
) -> Result<Response, ShellErrorOrRequestError> {
let data = match body {
Value::Int { .. } | Value::List { .. } | Value::String { .. } | Value::Record { .. } => {
Value::Int { .. } | Value::List { .. } | Value::Record { .. } => {
value_to_json_value(&body)?
}
// If the body type is string, assume it is string json content.
// If parsing fails, just send the raw string
Value::String { val: s, .. } => {
serde_json::from_str(&s).unwrap_or_else(|_| nu_json::Value::String(s))
}
_ => {
return Err(ShellErrorOrRequestError::ShellError(
ShellError::UnsupportedHttpBody {
Expand Down
2 changes: 1 addition & 1 deletion crates/nu-command/tests/commands/network/http/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn http_post_json_int_is_success() {
}

#[test]
fn http_post_json_string_is_success() {
fn http_post_json_raw_string_is_success() {
let mut server = Server::new();

let mock = server.mock("POST", "/").match_body(r#""test""#).create();
Expand Down

0 comments on commit 9f7a8cb

Please sign in to comment.