From 8631757ee8f8534779d5ae43f7f377699129bc6a Mon Sep 17 00:00:00 2001 From: Gary Krause Date: Tue, 31 Dec 2024 13:53:44 -0500 Subject: [PATCH] fix: better error handling --- src/sources/util/http_client.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/sources/util/http_client.rs b/src/sources/util/http_client.rs index a223d93e3324e..e8f5dca9f8cd4 100644 --- a/src/sources/util/http_client.rs +++ b/src/sources/util/http_client.rs @@ -219,11 +219,13 @@ pub(crate) async fn call< if status != 401 { return Ok(Err(crate::http::HttpError::DigestAuthExpectation)) } - let parts = response_headers - .get("www-authenticate") - .unwrap() - .to_str() - .unwrap(); + let parts = match response_headers.get("www-authenticate") { + Some(header_value) => match header_value.to_str() { + Ok(value) => value, + Err(_) => return Ok(Err(crate::http::HttpError::DigestAuthExpectation)), + }, + None => return Ok(Err(crate::http::HttpError::DigestAuthExpectation)), + }; let parts: Vec<&str> = parts.split(",").collect(); let mut realm = ""; let mut nonce = "";