From 3215c8f8dc1124b6dc09af0b0234f1bdccf4ea0e Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Fri, 19 Jan 2024 18:37:12 -0300 Subject: [PATCH] bugfix: deserialize_headers safely --- src/http/client.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/http/client.rs b/src/http/client.rs index 6b6c5566..a47b57a9 100644 --- a/src/http/client.rs +++ b/src/http/client.rs @@ -527,9 +527,11 @@ fn deserialize_headers(hashmap: HashMap) -> HeaderMap { let mut header_map = HeaderMap::new(); for (key, value) in hashmap { let key_bytes = key.as_bytes(); - let key_name = HeaderName::from_bytes(key_bytes).unwrap(); - let value_header = HeaderValue::from_str(&value).unwrap(); - header_map.insert(key_name, value_header); + if let Ok(key_name) = HeaderName::from_bytes(key_bytes) { + if let Ok(value_header) = HeaderValue::from_str(&value) { + header_map.insert(key_name, value_header); + } + } } header_map }