mirror of
https://github.com/nushell/nushell.git
synced 2025-02-17 02:50:56 +01:00
Parse the data from string to json if the `--content-type "application/json"` flag is used for the request. Fixes: https://github.com/nushell/nushell/issues/9408 In the issue, the actual data is a string `'{ "query": "{ greeting }" }'` representing json, and it would match the case `Value::String { val, .. }` ------------------------- The example in the issue does set the `content-type` to `application/json` but sends the body as a string note the `'`. ``` ( ::: http post ::: -fer ::: # -H [ "Content-Type" "application/json" ] ::: --content-type "application/json" ::: 'http://127.0.0.1:3000/greetings/hello' ::: '{ "query": "{ greeting }" }' ::: ) ``` ``` ╭─────────┬───────────────────────╮ │ headers │ {record 14 fields} │ │ body │ {"content_type":null} │ │ status │ 200 │ ╰─────────┴───────────────────────╯ ``` If we send the same request but using actual json as the body, the Header is set correctly. ``` ( ::: http post ::: -fer ::: # -H [ "Content-Type" "application/json" ] ::: --content-type "application/json" ::: 'http://127.0.0.1:3000/greetings/hello' ::: { "query": "{ greeting }" } ::: ) ``` ``` ╭─────────┬─────────────────────────────────────╮ │ headers │ {record 14 fields} │ │ body │ {"content_type":"application/json"} │ │ status │ 200 │ ╰─────────┴─────────────────────────────────────╯ ``` |
||
---|---|---|
.. | ||
assets | ||
src | ||
tests | ||
Cargo.toml | ||
LICENSE |