String values should pass their content-type correctly on http requests with a body (e.g. http post) (#13731)

# Description
The content-type was not being handled appropriately when sending
requests with a string value.

# User-Facing Changes
- Passing a string value through a pipeline with a content-type set as
metadata is handled correctly
- Passing a string value as a parameter with a content-type set as a
flag is handled correctly.
This commit is contained in:
Jack Wright
2024-09-05 16:29:50 -07:00
committed by GitHub
parent d0c2adabf7
commit 2d360fda7f
5 changed files with 48 additions and 16 deletions

View File

@ -115,6 +115,24 @@ fn http_post_json_is_success() {
assert!(actual.out.is_empty())
}
#[test]
fn http_post_json_string_is_success() {
let mut server = Server::new();
let mock = server
.mock("POST", "/")
.match_body(r#"{"foo":"bar"}"#)
.create();
let actual = nu!(format!(
r#"http post -t 'application/json' {url} '{{"foo":"bar"}}'"#,
url = server.url()
));
mock.assert();
assert!(actual.out.is_empty())
}
#[test]
fn http_post_json_list_is_success() {
let mut server = Server::new();
@ -149,7 +167,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();