From 8346f0d59b11d4663c43ac3c2ec335eb162d1945 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 19 Mar 2019 12:50:15 +0100 Subject: [PATCH] src/server/rest.rs: correctly extract content type --- src/server/rest.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/server/rest.rs b/src/server/rest.rs index 87401f4e..022155db 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -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")))); + } } }