Skip to content

Commit

Permalink
fix: better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
average-gary committed Dec 31, 2024
1 parent 59679e0 commit 8631757
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/sources/util/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down

0 comments on commit 8631757

Please sign in to comment.