Convert content-type to lowercase for comparison

This commit is contained in:
Felix Ableitner 2024-06-10 12:11:52 +02:00
parent 175b22006b
commit e398376ab6

View file

@ -65,9 +65,9 @@ pub async fn fetch_object_http<T: Clone, Kind: DeserializeOwned>(
let content_type = res let content_type = res
.content_type .content_type
.as_ref() .as_ref()
.and_then(|c| c.to_str().ok()) .and_then(|c| Some(c.to_str().ok()?.to_lowercase()))
.ok_or(Error::FetchInvalidContentType(res.url.clone()))?; .ok_or(Error::FetchInvalidContentType(res.url.clone()))?;
if !VALID_RESPONSE_CONTENT_TYPES.contains(&content_type) { if !VALID_RESPONSE_CONTENT_TYPES.contains(&content_type.as_str()) {
return Err(Error::FetchInvalidContentType(res.url)); return Err(Error::FetchInvalidContentType(res.url));
} }