From 87c0791d535fd9a1a248dd1b146b65ccac106dd2 Mon Sep 17 00:00:00 2001 From: Maximilian Nitsch Date: Tue, 26 Jul 2022 14:10:36 +0200 Subject: [PATCH] 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 --- api_client/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_client/src/lib.rs b/api_client/src/lib.rs index f9c9ff409..8583def4e 100644 --- a/api_client/src/lib.rs +++ b/api_client/src/lib.rs @@ -131,7 +131,7 @@ fn parse_http_response(socket: &mut dyn Read) -> Result, 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() {