From d7f6fc4db563c1f7eec604a7f25b7eb6182d5789 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 25 Aug 2023 08:36:19 +0200 Subject: [PATCH] client: fix content type parsing with included charset Signed-off-by: Wolfgang Bumiller --- proxmox-client/src/lib.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/proxmox-client/src/lib.rs b/proxmox-client/src/lib.rs index 06f57ff4..2bf01d8f 100644 --- a/proxmox-client/src/lib.rs +++ b/proxmox-client/src/lib.rs @@ -82,20 +82,20 @@ impl HttpApiResponse { } fn assert_json_content_type(&self) -> Result<(), Error> { - match self.content_type.as_deref() { + match self + .content_type + .as_deref() + .and_then(|v| v.split(';').next()) + { Some("application/json") => Ok(()), - Some(other) => { - Err(Error::BadApi( - format!("expected json body, got {other}",), - None, - )) - } - None => { - Err(Error::BadApi( - "expected json body, but no Content-Type was sent".to_string(), - None, - )) - } + Some(other) => Err(Error::BadApi( + format!("expected json body, got {other}",), + None, + )), + None => Err(Error::BadApi( + "expected json body, but no Content-Type was sent".to_string(), + None, + )), } }