mirror of
https://github.com/fafhrd91/actix-web
synced 2025-01-31 11:02:08 +01:00
fix limit not working on HttpMessageBody::limit (#1938)
This commit is contained in:
parent
c201c15f8c
commit
51e54dac8b
@ -289,10 +289,12 @@ impl HttpMessageBody {
|
|||||||
if let Some(l) = req.headers().get(&header::CONTENT_LENGTH) {
|
if let Some(l) = req.headers().get(&header::CONTENT_LENGTH) {
|
||||||
match l.to_str() {
|
match l.to_str() {
|
||||||
Ok(s) => match s.parse::<usize>() {
|
Ok(s) => match s.parse::<usize>() {
|
||||||
Ok(l) if l > DEFAULT_CONFIG_LIMIT => {
|
Ok(l) => {
|
||||||
err = Some(PayloadError::Overflow)
|
if l > DEFAULT_CONFIG_LIMIT {
|
||||||
|
err = Some(PayloadError::Overflow);
|
||||||
|
}
|
||||||
|
length = Some(l)
|
||||||
}
|
}
|
||||||
Ok(l) => length = Some(l),
|
|
||||||
Err(_) => err = Some(PayloadError::UnknownLength),
|
Err(_) => err = Some(PayloadError::UnknownLength),
|
||||||
},
|
},
|
||||||
Err(_) => err = Some(PayloadError::UnknownLength),
|
Err(_) => err = Some(PayloadError::UnknownLength),
|
||||||
@ -316,9 +318,11 @@ impl HttpMessageBody {
|
|||||||
/// Change max size of payload. By default max size is 256kB
|
/// Change max size of payload. By default max size is 256kB
|
||||||
pub fn limit(mut self, limit: usize) -> Self {
|
pub fn limit(mut self, limit: usize) -> Self {
|
||||||
if let Some(l) = self.length {
|
if let Some(l) = self.length {
|
||||||
if l > limit {
|
self.err = if l > limit {
|
||||||
self.err = Some(PayloadError::Overflow);
|
Some(PayloadError::Overflow)
|
||||||
}
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
}
|
}
|
||||||
self.limit = limit;
|
self.limit = limit;
|
||||||
self
|
self
|
||||||
|
Loading…
x
Reference in New Issue
Block a user