From 04512d3068d0bfb7519c7a9c3fe3d6a41e7f89a1 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 25 Jul 2019 12:17:35 +0200 Subject: [PATCH] src/client/http_client.rs: allow upload with parameters --- src/client/http_client.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/client/http_client.rs b/src/client/http_client.rs index 22cdd431..0c746659 100644 --- a/src/client/http_client.rs +++ b/src/client/http_client.rs @@ -248,10 +248,24 @@ impl HttpClient { }) } - pub fn upload(&mut self, content_type: &str, body: Body, path: &str) -> impl Future { + pub fn upload( + &mut self, + content_type: &str, + body: Body, + path: &str, + data: Option, + ) -> impl Future { let path = path.trim_matches('/'); - let url: Uri = format!("https://{}:8007/{}", &self.server, path).parse().unwrap(); + let mut url = format!("https://{}:8007/{}", &self.server, path); + + if let Some(data) = data { + let query = tools::json_object_to_query(data).unwrap(); + url.push('?'); + url.push_str(&query); + } + + let url: Uri = url.parse().unwrap(); let req = Request::builder() .method("POST")