1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2025-04-10 11:54:06 +00:00

Cleanup len parse code

This commit is contained in:
messense 2019-06-27 23:34:21 +08:00
parent 552db77fc7
commit 539e8c11ec

View file

@ -322,14 +322,11 @@ where
};
}
let mut len = None;
if let Some(l) = req.headers().get(&CONTENT_LENGTH) {
if let Ok(s) = l.to_str() {
if let Ok(l) = s.parse::<usize>() {
len = Some(l)
}
}
}
let len = req
.headers()
.get(&CONTENT_LENGTH)
.and_then(|l| l.to_str().ok())
.and_then(|s| s.parse::<usize>().ok());
let payload = Decompress::from_headers(payload.take(), req.headers());
JsonBody {