From 4898750fc1cbe4d181ee342a72e6ac760a68183d Mon Sep 17 00:00:00 2001 From: Reilly Wood <26268125+rgwood@users.noreply.github.com> Date: Mon, 6 Mar 2023 08:49:28 -0800 Subject: [PATCH] Remove body parameters from `http get` (#8336) `http get` has 2 parameters which are used for setting the body of the HTTP request. They don't make sense because [GET requests should have no body](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET): ![image](https://user-images.githubusercontent.com/26268125/223032130-764d0313-df00-48a6-80a5-0d8ff296b8ae.png) --- crates/nu-command/src/network/http/get.rs | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/crates/nu-command/src/network/http/get.rs b/crates/nu-command/src/network/http/get.rs index 781e196d48..48a96a59b4 100644 --- a/crates/nu-command/src/network/http/get.rs +++ b/crates/nu-command/src/network/http/get.rs @@ -39,13 +39,6 @@ impl Command for SubCommand { "the password when authenticating", Some('p'), ) - .named("data", SyntaxShape::Any, "the content to post", Some('d')) - .named( - "content-type", - SyntaxShape::Any, - "the MIME type of content to post", - Some('t'), - ) .named( "max-time", SyntaxShape::Int, @@ -113,16 +106,6 @@ impl Command for SubCommand { example: "http get -H [my-header-key my-header-value] https://www.example.com", result: None, }, - Example { - description: "Get content from example.com, with body", - example: "http get -d 'body' https://www.example.com", - result: None, - }, - Example { - description: "Get content from example.com, with JSON body", - example: "http get -t application/json -d { field: value } https://www.example.com", - result: None, - }, ] } } @@ -130,8 +113,6 @@ impl Command for SubCommand { struct Arguments { url: Value, headers: Option, - data: Option, - content_type: Option, raw: bool, insecure: bool, user: Option, @@ -148,8 +129,6 @@ fn run_get( let args = Arguments { url: call.req(engine_state, stack, 0)?, headers: call.get_flag(engine_state, stack, "headers")?, - data: call.get_flag(engine_state, stack, "data")?, - content_type: call.get_flag(engine_state, stack, "content-type")?, raw: call.has_flag("raw"), insecure: call.has_flag("insecure"), user: call.get_flag(engine_state, stack, "user")?, @@ -177,7 +156,7 @@ fn helper( request = request_add_authorization_header(args.user, args.password, request); request = request_add_custom_headers(args.headers, request)?; - let response = send_request(request, span, args.data, args.content_type); + let response = send_request(request, span, None, None); request_handle_response( engine_state, stack,