mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
api-client: Handle body_offset is None
Handle the case `body_offset` is `None` instead of calling `unwrap()` which leads to a panic. Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
This commit is contained in:
parent
c46a9592c0
commit
87c0791d53
@ -131,7 +131,7 @@ fn parse_http_response(socket: &mut dyn Read) -> Result<Option<String>, Error> {
|
||||
}
|
||||
}
|
||||
}
|
||||
let body_string = content_length.and(Some(String::from(&res[body_offset.unwrap()..])));
|
||||
let body_string = content_length.and(body_offset.map(|o| String::from(&res[o..])));
|
||||
let status_code = get_status_code(&res)?;
|
||||
|
||||
if status_code.is_server_error() {
|
||||
|
Loading…
Reference in New Issue
Block a user