src/server/rest.rs: correctly extract content type
This commit is contained in:
parent
164d961729
commit
8346f0d59b
|
@ -120,14 +120,18 @@ fn get_request_parameters_async(
|
||||||
let mut is_json = false;
|
let mut is_json = false;
|
||||||
|
|
||||||
if let Some(value) = parts.headers.get(header::CONTENT_TYPE) {
|
if let Some(value) = parts.headers.get(header::CONTENT_TYPE) {
|
||||||
if value == "application/x-www-form-urlencoded" {
|
match value.to_str().map(|v| v.split(';').next()) {
|
||||||
|
Ok(Some("application/x-www-form-urlencoded")) => {
|
||||||
is_json = false;
|
is_json = false;
|
||||||
} else if value == "application/json" {
|
}
|
||||||
|
Ok(Some("application/json")) => {
|
||||||
is_json = true;
|
is_json = true;
|
||||||
} else {
|
}
|
||||||
|
_ => {
|
||||||
return Box::new(future::err(http_err!(BAD_REQUEST, format!("unsupported content type"))));
|
return Box::new(future::err(http_err!(BAD_REQUEST, format!("unsupported content type"))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let resp = req_body
|
let resp = req_body
|
||||||
.map_err(|err| http_err!(BAD_REQUEST, format!("Promlems reading request body: {}", err)))
|
.map_err(|err| http_err!(BAD_REQUEST, format!("Promlems reading request body: {}", err)))
|
||||||
|
|
Loading…
Reference in New Issue