mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 11:22:26 +00:00
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 <robert.bradford@intel.com>
This commit is contained in:
parent
a60b437f89
commit
654846f433
@ -122,7 +122,7 @@ fn get_status_code(res: &str) -> Result<StatusCode, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_http_response(socket: &mut UnixStream) -> Result<Option<String>, Error> {
|
||||
fn parse_http_response(socket: &mut dyn Read) -> Result<Option<String>, Error> {
|
||||
let mut res = String::new();
|
||||
let mut body_offset = None;
|
||||
let mut content_length: Option<usize> = None;
|
||||
@ -165,8 +165,8 @@ fn parse_http_response(socket: &mut UnixStream) -> Result<Option<String>, Error>
|
||||
}
|
||||
}
|
||||
|
||||
fn simple_api_command(
|
||||
socket: &mut UnixStream,
|
||||
fn simple_api_command<T: Read + Write>(
|
||||
socket: &mut T,
|
||||
method: &str,
|
||||
c: &str,
|
||||
request_body: Option<&str>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user