From f0cfbe0befbc52f0edc7167bd5fd701a87dc9fd7 Mon Sep 17 00:00:00 2001 From: shikai liu Date: Thu, 30 May 2024 08:33:11 +0800 Subject: [PATCH 1/4] Update the version. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3907121..7affe15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rcurl" -version = "0.0.25" +version = "0.0.26" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 82fead0d6a334144cf5d5c73effe8dbcec5a2045 Mon Sep 17 00:00:00 2001 From: Shikai Liu Date: Thu, 30 May 2024 20:33:07 +0800 Subject: [PATCH 2/4] Update the gitignore. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d105c32..cb3c01a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ Cargo.lock *.pdb .idea *.profraw -*.html \ No newline at end of file +*.html +.vscode \ No newline at end of file From 71311233d88fb0d91a4607968b9c89311903e19c Mon Sep 17 00:00:00 2001 From: shikai liu Date: Thu, 6 Jun 2024 16:57:11 +0800 Subject: [PATCH 3/4] Add the command upload-file. --- src/http/handler.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/http/handler.rs b/src/http/handler.rs index 18874db..78fca58 100644 --- a/src/http/handler.rs +++ b/src/http/handler.rs @@ -222,6 +222,9 @@ pub async fn http_request( method = String::from("POST"); content_type_option = Some(String::from("application/x-www-form-urlencoded")); } + if cli.uploadfile_option.is_some() { + method = String::from("PUT"); + } if let Some(method_userdefined) = cli.method_option.clone() { method = method_userdefined; } @@ -287,6 +290,9 @@ pub async fn http_request( body_bytes = bytes.into(); } else if let Some(body) = cli.body_option.clone() { body_bytes = Bytes::from(body); + } else if let Some(upload_file) = cli.uploadfile_option.clone() { + let byte_vec = tokio::fs::read(upload_file).await?; + body_bytes = Bytes::from(byte_vec); } if cli.header_option { From 846b0b41f1ab7d642137e5a7ad08cab1d80e59ce Mon Sep 17 00:00:00 2001 From: shikai liu Date: Fri, 7 Jun 2024 08:29:10 +0800 Subject: [PATCH 4/4] Update the README.md. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index cd734c8..37faffe 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,10 @@ rcurl -A 'a:b' http://httpbin.org/get ``` rcurl -b 'a:b' http://httpbin.org/get ``` +## Upload File +``` +rcurl --upload-file .gitignore http://httpbin.org/put +``` ## Http2 ### Default ```