diff --git a/src/net/headers/accept.rs b/src/net/headers/accept.rs index 7191192f..b433d3c8 100644 --- a/src/net/headers/accept.rs +++ b/src/net/headers/accept.rs @@ -36,8 +36,10 @@ impl Header for Accept { I: Iterator, { let value = values.next().ok_or_else(headers::Error::invalid)?; + let parts: Vec<&str> = + value.to_str().map_err(|_| headers::Error::invalid())?.split(';').collect(); - match value.to_str().map_err(|_| headers::Error::invalid())? { + match parts[0] { "text/plain" => Ok(Accept::TextPlain), "application/json" => Ok(Accept::ApplicationJson), "application/cbor" => Ok(Accept::ApplicationCbor), diff --git a/src/net/headers/content_type.rs b/src/net/headers/content_type.rs index 9bff7b57..90183508 100644 --- a/src/net/headers/content_type.rs +++ b/src/net/headers/content_type.rs @@ -36,8 +36,10 @@ impl Header for ContentType { I: Iterator, { let value = values.next().ok_or_else(headers::Error::invalid)?; + let parts: Vec<&str> = + value.to_str().map_err(|_| headers::Error::invalid())?.split(';').collect(); - match value.to_str().map_err(|_| headers::Error::invalid())? { + match parts[0] { "text/plain" => Ok(ContentType::TextPlain), "application/json" => Ok(ContentType::ApplicationJson), "application/cbor" => Ok(ContentType::ApplicationCbor),