From 654846f433b6cece5719a1a9ba32fd3d217bcdac Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 23 Oct 2020 11:03:22 +0100 Subject: [PATCH] bin: ch-remote: Generalise functions that work on a HTTP socket Use the trait for Read/Write rather than specifying the concrete type. This allows for the functionality to be used for different socket types. Signed-off-by: Rob Bradford --- src/bin/ch-remote.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin/ch-remote.rs b/src/bin/ch-remote.rs index 66cc69183..e598b63a4 100644 --- a/src/bin/ch-remote.rs +++ b/src/bin/ch-remote.rs @@ -122,7 +122,7 @@ fn get_status_code(res: &str) -> Result { } } -fn parse_http_response(socket: &mut UnixStream) -> Result, Error> { +fn parse_http_response(socket: &mut dyn Read) -> Result, Error> { let mut res = String::new(); let mut body_offset = None; let mut content_length: Option = None; @@ -165,8 +165,8 @@ fn parse_http_response(socket: &mut UnixStream) -> Result, Error> } } -fn simple_api_command( - socket: &mut UnixStream, +fn simple_api_command( + socket: &mut T, method: &str, c: &str, request_body: Option<&str>,