]> git.proxmox.com Git - proxmox-backup.git/commitdiff
src/server/rest.rs: correctly extract content type
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 19 Mar 2019 11:50:15 +0000 (12:50 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 19 Mar 2019 11:50:15 +0000 (12:50 +0100)
src/server/rest.rs

index 87401f4e518bf83a8c5c2852f66bb6508a31920b..022155db6695c34e93c6b24d01ee4c964824ce65 100644 (file)
@@ -120,12 +120,16 @@ fn get_request_parameters_async(
     let mut is_json = false;
 
     if let Some(value) = parts.headers.get(header::CONTENT_TYPE) {
-        if value == "application/x-www-form-urlencoded" {
-            is_json = false;
-        } else if value == "application/json" {
-            is_json = true;
-        } else {
-            return Box::new(future::err(http_err!(BAD_REQUEST, format!("unsupported content type"))));
+        match value.to_str().map(|v| v.split(';').next()) {
+            Ok(Some("application/x-www-form-urlencoded")) => {
+                is_json = false;
+            }
+            Ok(Some("application/json")) => {
+                is_json = true;
+            }
+            _ => {
+                return Box::new(future::err(http_err!(BAD_REQUEST, format!("unsupported content type"))));
+            }
         }
     }